Creating Azure Function App#
Note
We'll create the Azure Function using Azure Portal, but this can also be done via VS Code or Azure CLI.
Create Function App in Azure Portal#
- Select resource group
az-func-demo-wus - Click
+Createin the overview tab - Search for
Function Appin marketplace and clickcreate
Configuration Options#
| Setting | Value |
|---|---|
| Function App name | function-demo (globally unique) |
| Publish | Code |
| Runtime stack | Python |
| Version | 3.9 |
| Region | West US |
| Operating System | Linux |
| Plan Type | Consumption |
- Under Monitoring tab, ensure Application Insight is enabled
- Under Deployment tab, link your GitHub repository
- Click
Review+Createand wait for deployment
Refresh VS Code#
- Click on
Azure extension→Resources→Function App→ Refresh
Tip
If refresh doesn't work, try re-authenticating: Press Cmd+Shift+P and select Azure: Sign Out, then login again.
Create Function from VS Code#
- Click
Azure extension→Workspace→+icon →Create HTTP Function - Select Python as language
- Select python3.9 as interpreter
- Name your function:
functiondemo
VS Code will create this structure:
.
├── README.md
├── host.json
├── local.settings.json
├── requirements.txt
└── functiondemo
├── __init__.py
├── function.json
└── sample.dat
Test Locally#
- Add
.vscode,.venv,__pycache__to.gitignore - Run →
Run Without Debugging - Test the endpoint:
http://localhost:7071/api/functiondemo
Deploy to Azure#
git add .
git commit -m "First Commit"
git push
Once GitHub Action completes, verify at: https://function-demo.azurewebsites.net/api/functiondemo