- In VSCode, open the root folder
- Install all dependencies using
- Install Azure CLI on youre machine.
- Install Azure Function Core tools globaly using
npm i -g firstname.lastname@example.org(version 2).
- In a Node.js console, build the solution using
npm run build:devcmd. For production use, execute
npm run build(minified version of the JS code).
- In a Node.js console, from the
functions/distfolder, run the following command
- In VSCode, launch the 'Debug Local Azure Function' debug configuration
- Set breakpoints directly in your '.ts' files
Send your requests either using Postman with the localhost address according to your settings (i.e.
http://localhost:7071/api/enhanceQuery) or directly in the 'Search Box Webpart' via the 'Service URL' parameter. For the last scenario you can use
npm i -g ngrokto redirect calls to your localhost function using the following command
ngrok http 7071.
Azure Function Proxy configuration¶
This solution uses an Azure function proxy to get an only single endpoint URL for multiple functions. See the proxies.json file to see defined routes.
How to deploy the solution to Azure ?¶
We recommend to use Visual Studio Code to work with this solution.
- In VSCode, download the Azure Function extension
- Sign-in to to Azure account into the extension
- In a Node.js console, build the application using the command
npm run build(minified version)
- Use the "Deploy to Function App" feature (in the extension top bar) using the 'dist' folder. Make sure you've run the
npm run buildcmd before.
- Upload the application settings (
Production scenario with CI¶
deploy.ps1 script is available to also deploy this function into your Azure environment.
- From you Azure portal, create a new empty function
- Set the
Azure_Function_Namevalue in the
- Login to Azure using
az loginthen run
deploy.ps1script with your parameters.
- If you use Azure DevOps, you can simply use the default build template and release task for Azure Functions ommiting this script.
In both scenarios, you can test your function using Postman. If you test it using a SPFx component, don't forget to add the SharePoint domain to the CORS settings to allow this origin: