10.3 Configure & Deploy Function Apps
Key Takeaways
- App settings store connection strings, AI endpoint URLs, and feature flags; prefer Key Vault references and managed identities over secrets in code
- Hosting plans (Consumption vs Premium vs Dedicated) trade cost for cold-start behavior and VNet features — Premium is often chosen for latency-sensitive AI APIs
- Deploy with zip deploy, VS Code/Core Tools, GitHub Actions/Azure DevOps CI, or deployment slots for safer releases
- Slots enable staged swap of Function App versions without downtime when supported on the plan
- Configure CORS, scaling, runtime version, and Application Insights as part of production Function App setup
Building triggers and HTTP APIs is only half of the AI-200 skill. You must also configure and deploy Function Apps so they run securely, scale under AI traffic, and ship updates without breaking production chat or document pipelines.
Function App configuration essentials
A Function App is an App Service specialization. Configuration lives primarily in Application settings (environment variables at runtime). Your code reads settings such as AZURE_OPENAI_ENDPOINT, storage connection names referenced by bindings, and feature flags.
| Setting area | Examples | Exam tip |
|---|---|---|
| Runtime | FUNCTIONS_WORKER_RUNTIME (dotnet-isolated, python, node, …) | Must match your language stack |
| Storage | AzureWebJobsStorage | Required by the host for locks, triggers, and internal state |
| Extensions | Binding connection names (MyBlobStorage, Service Bus conn) | Bindings resolve connections from app settings |
| AI services | Endpoint URLs, deployment names | Prefer managed identity; avoid raw keys in settings when possible |
| Secrets | Key Vault references (@Microsoft.KeyVault(...)) | Secrets stay in Key Vault; settings hold references |
| Hosting | Plan, region, OS (Linux/Windows) | Affects cold start, cost, and scaling |
Managed identity and Key Vault
Enable a system-assigned or user-assigned managed identity on the Function App. Grant that identity roles such as Cognitive Services OpenAI User, Storage Blob Data Reader, or Key Vault Secrets User. Then:
- Call Azure OpenAI with token credentials instead of API keys when supported.
- Store remaining secrets in Key Vault and reference them from app settings.
Exam distractors often show connection strings pasted into source files — always choose configuration + identity over hard-coding.
Hosting plans and AI latency
| Plan | Billing model | Cold starts | Notable features |
|---|---|---|---|
| Consumption | Per execution + resource consumption | Possible after idle | Scale to zero; lowest idle cost |
| Premium (Elastic Premium) | Pre-warmed instances + execution | Reduced / avoidable with pre-warmed | VNet integration, longer run duration, better for chat APIs |
| Dedicated (App Service plan) | Always-on VM-like plan | Predictable if Always On | Familiar App Service isolation |
Why Premium matters for AI backends
Interactive AI APIs are sensitive to tail latency. On Consumption, an idle Function App may cold-start: the platform allocates a worker, loads the language worker, and then runs your code — adding seconds before the first token streams back. Premium plans keep pre-warmed instances so HTTP-triggered chat backends feel snappier. Premium also supports regional VNet integration, useful when the function must reach private Azure OpenAI, AI Search, or storage endpoints.
Choose Consumption for bursty, cost-sensitive batch workers (queue-triggered embedding jobs) where an occasional cold start is acceptable. Choose Premium (or Dedicated with Always On) when AI-200 scenarios emphasize low-latency user-facing APIs or private networking.
Deployment options
| Method | How it works | Typical use |
|---|---|---|
| Zip deploy | Upload a zip of the app package to the Kudu/scm endpoint or via Azure CLI | Simple CI steps, Core Tools publish |
| Azure Functions Core Tools / VS Code | func azure functionapp publish | Local developer publish |
| CI/CD (GitHub Actions, Azure DevOps) | Build → test → deploy pipeline | Team production releases |
| Run-From-Package | App runs directly from a mounted zip package | Atomic, immutable deployments |
| Deployment slots | Stage in a slot, then swap to production | Blue-green style releases |
| Container | Deploy Functions in a custom container | Custom dependencies, advanced isolation |
Zip deploy and Run-From-Package
Zip deploy packages your compiled functions and dependencies. With Run-From-Package, the platform mounts the zip as a read-only filesystem, which reduces file-lock issues and makes deployments atomic — a common best practice for Node and .NET publish outputs. Azure CLI and GitHub Actions templates often set WEBSITE_RUN_FROM_PACKAGE accordingly.
Deployment slots
On plans that support slots (Premium and Dedicated; not classic Consumption the same way), you deploy to a staging slot, validate HTTP health and a smoke inference call, then swap into production. Swap keeps sticky settings you mark as slot-specific (for example, a staging Azure OpenAI deployment name) while moving the code. This reduces downtime and makes rollback a reverse swap.
CI/CD checklist for AI Function Apps
- Build and run unit tests (including binding/trigger metadata validation where applicable).
- Deploy to a slot or test Function App.
- Apply infrastructure settings (app settings, identity role assignments) via Bicep/Terraform — not manual portal-only drift.
- Smoke-test: anonymous health endpoint OK; authenticated completion endpoint returns 200.
- Swap or promote; watch Application Insights for error rate spikes.
Never commit local.settings.json secrets to git; that file is for local Core Tools only. Production uses app settings / Key Vault.
Networking, CORS, and scaling knobs
- CORS: Allow specific SPA origins on the Function App or terminate CORS at API Management.
- Scale out: Consumption and Premium scale out based on trigger load (HTTP concurrency, queue length). Understand that each instance may open connections to Azure OpenAI — watch service throttling (
429) and use retries with backoff. - Runtime version: Pin a supported Functions runtime major version; upgrades can change extension bundles.
- Extension bundles: Non-.NET languages often rely on extension bundles for binding support — keep them current in
host.jsonguidance from Microsoft docs.
host.json vs app settings
| File / store | Controls |
|---|---|
host.json | Host behavior: logging, extension options, queue batch sizes, HTTP route prefix, sampling |
| App settings | Environment-specific values: connections, endpoints, keys/references, runtime |
local.settings.json | Local emulation only — not deployed as production config |
For AI workers, host.json might tune queue batch size so document jobs process efficiently without overwhelming the model endpoint. App settings still hold the endpoint URL and deployment name.
Monitoring after deploy
Connect Application Insights during Function App creation or afterward. Use live metrics during a slot swap. Set alerts on failed function executions and dependency failures to Azure OpenAI. Log Analytics queries help prove whether latency is cold start, model time, or downstream storage.
End-to-end production picture
- Create Function App on Premium if the AI API is user-facing and latency-sensitive; use Consumption for async queue workers if cost dominates.
- Enable managed identity; grant access to Storage, Key Vault, and Azure AI resources.
- Configure app settings and Key Vault references; set
FUNCTIONS_WORKER_RUNTIME. - Deploy via CI zip deploy / Run-From-Package into a slot, smoke-test, swap.
- Monitor with Application Insights; tune scale and plan if cold starts or throttling appear.
Key Takeaways
- App settings + Key Vault references + managed identity are the secure configuration pattern.
- Consumption scales to zero but can cold-start; Premium reduces latency for AI HTTP APIs and adds VNet options.
- Zip deploy, Run-From-Package, CI/CD, and deployment slots are the main deployment tools.
- Keep secrets out of source; use slots for safer releases; monitor with Application Insights.
Your team’s interactive Azure OpenAI chat API runs on Azure Functions and users complain about multi-second delays on the first request after idle periods. Which hosting change most directly addresses cold starts?
Where should production connection strings and Azure OpenAI configuration for a Function App primarily live?
Which deployment approach lets you validate a new Function App build in staging and then move it to production with a swap?