03: Creating Azure Function App
Creating Azure Function App using Azure Portal
- Select resource group
az-func-demo-wus - Click on
+Createbutton in overview tab. - Search for
Function Appin marketplace and clickcreate - In
Create Function Apppage:- Ensure right subscription and resource group are selected.
- Function App name: Provide a unique name to Azure Function. Azure Function name are globally unique. I have selected
function-demo. - Publish: code
- Runtime stack: Python
- Version: 3.9
- Region: West US
- Operating System: Linux
- Plan Type: Consumption
- Skip
Hostingtab - Skip
Networkingtab - Under
Monitoringtab, ensure Application Insight is enabled. - Under
Deploymenttab, link Github repository that we created. - Click
Review+Create - Wait for Azure Deployment to complete.
Refresh VS Code for Azure Function App
- Click on
Azure extension>Resources>Function App> Click on Refresh.
Cmd+Shift+P and select Azure: Sign Out and then login.
At this point, we have Azure Function App created. Now it is the time to create a Function.
Create Function from VS Code
-
Click on
Azure extension>Workspace> Click on+icon > SelectCreate HTTP Function -
Select language as
Python -
Select Python interpreter as
python3.9 -
Provide a Name for Function. Scope of this name is within Function App. Hence, it should only be unique within Function App but not globally. Lets name it
functiondemo -
VS Code should start creating virtual Environment and skeleton code for Function. We will see following directory structure or similar.
. ├── README.md ├── host.json ├── local.settings.json ├── requirements.txt └── functiondemo ├── __init__.py ├── function.json └── sample.dat -
Lets add a
.gitignorefile and add.vscode,.venv,__pycache__to it. -
Click on
Run Menu>Run Without Debugging. This should start function locally with an API endpoint similar tofunctiondemo: [GET,POST] http://localhost:7071/api/functiondemo -
Verify if we are getting response from function endpoint locally using
http://localhost:7071/api/functiondemo -
Once verified, Push the code to GitHub origin. This should trigger GitHub Action to deploy sample code to Azure Function App and create a function with name
functiondemogit add . git status git commit -m "First Commit" git push -
Once GitHub Action is completed, verify response using Azure Function URL. If Azure Function url is
https://function-demo.azurewebsites.net, then append/api/functiondemoto test. For example:https://function-demo.azurewebsites.net/api/functiondemo