Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Execute Azure deployments using azd, Terraform, or Bicep with built-in error recovery.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/recipes/azd/functions-deploy.md
1# Azure Functions Deployment23Deployment workflows for Azure Functions using AZD.45## Prerequisites67- Azure Functions project prepared with azd template8- `azure.yaml` exists and validated9- `.azure/deployment-plan.md` status = `Validated`10- Azure Functions Core Tools (optional, for local debugging or when using `func` commands outside azd workflows)1112## AZD Deployment1314### Full Deployment (Infrastructure + Code)1516```bash17# Deploy everything18azd up --no-prompt19```2021### Infrastructure Only2223```bash24# Provision infrastructure without deploying code25azd provision --no-prompt26```2728### Application Only2930```bash31# Deploy code to existing infrastructure32azd deploy --no-prompt33```3435### Preview Changes3637```bash38# Preview changes before deployment39azd provision --preview40```4142## Environment Configuration4344### Set AZD Environment Variables4546These are for azd provisioning, not application runtime:4748```bash49azd env set AZURE_LOCATION eastus250azd env set VNET_ENABLED false51```5253> ⚠️ **Important**: `azd env set` sets variables for the azd provisioning process, NOT application environment variables.5455## Verify Deployment5657### Check Function App Status5859```bash60# Show deployment details61azd show62```6364## Testing HTTP Endpoints6566> ⚠️ **Never use `curl -I` (HEAD) to test Azure Functions endpoints.**67>68> Azure Functions `[HttpTrigger]` with `"get"` does **not** automatically handle HEAD requests. HEAD returns 404 from the routing layer even when GET works correctly, causing false-negative results and misdirected debugging.6970### ✅ DO — Use GET with output suppression7172```bash73# Check status code only (GET, don't follow redirects)74curl -s -o /dev/null -w "%{http_code}" "https://<func-name>.azurewebsites.net/api/<route>"7576# Get status code and redirect URL77curl -s -o /dev/null -w "Status: %{http_code}\nRedirect: %{redirect_url}" "https://<func-name>.azurewebsites.net/api/<route>"7879# Verbose output showing response headers (GET)80curl -sS -D - -o /dev/null "https://<func-name>.azurewebsites.net/api/<route>"81```8283### ❌ DON'T — Use HEAD requests8485```bash86# DO NOT use this — returns 404 even when the function works87curl -I "https://<func-name>.azurewebsites.net/api/<route>"88```8990## Monitoring9192Monitor your Functions deployment through Azure Portal or use azd to view deployment status.9394### Common Issues95961. **Deployment timeout**: Use `azd up` with appropriate timeout settings972. **Missing dependencies**: Ensure package.json/requirements.txt is correct and committed983. **Function not appearing**: Check azure.yaml service configuration994. **Cold start issues**: Consider Premium plan configuration in Bicep templates100101## CI/CD Integration102103For automated deployments with azd, see [cicd/README.md](../cicd/README.md) for GitHub Actions and Azure DevOps integration.104105## Data Loss Warning106107> ⚠️ **CRITICAL: `azd down` Data Loss Warning**108>109> `azd down` **permanently deletes ALL resources** in the environment, including:110> - **Function Apps** with all configuration and deployment slots111> - **Storage accounts** with all blobs and files112> - **Key Vault** with all secrets (use `--purge` to bypass soft-delete)113> - **Databases** with all data (Cosmos DB, SQL, etc.)114>115> **Best practices:**116> - Always use `azd provision --preview` before `azd up`117> - Use separate environments for dev/staging/production118> - Back up important data before running `azd down`119120## Next Steps121122After deployment:1231. Verify functions are running1242. Test endpoints1253. Monitor Application Insights1264. Set up alerts and monitoring127