Configure and Deploy Function Apps
30-second answer
A function app is configured in three places: host.json (runtime behaviour for every function, deployed with the code), app settings (environment variables in Azure, replacing local.settings.json, which never gets deployed) and the hosting plan. Flex Consumption is the recommended serverless plan: it scales to zero, adds always-ready instances if you want no cold starts and supports virtual networks. You create one with az functionapp create --flexconsumption-location and deploy with func azure functionapp publish or a zip deploy. Identity-based connections replace connection strings with settings like ServiceBusConnection__fullyQualifiedNamespace.
Exam objective: 3.2.2 Configure and deploy function apps. (Skills measured as of October 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Settings → Environment variables</strong>. The <code>__fullyQualifiedNamespace</code> suffix tells the Service Bus trigger to use the managed identity.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Settings → Environment variables. The __fullyQualifiedNamespace suffix tells the Service Bus trigger to use the managed identity.
- Add the model deployment name your code reads with os.environ.
- Select Apply and confirm. The app restarts and picks up the new value; no redeploy needed.
- Now ship the code. Zip the project and deploy the package. Flex Consumption stores it in a blob container and runs it from there.
- For every push, Deployment Center can set up a GitHub Actions workflow that does the same deploy.
- Finally, Scale and concurrency: cap the instance count so a burst of messages can’t run up the bill. Prices are per GB-second after the free grant.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Functions scale with the work
On the Flex Consumption plan a function app adds instances as messages arrive and scales to zero when idle. Premium keeps warm instances to avoid cold starts. Settings live in app settings, and you deploy a zip package or a container.
🤔 What happens if…
Read this tour as text
- Don’t make users wait. Summarising a 40-page PDF takes a minute. If the web API does it inline, requests pile up and time out. Put a message on a queue instead, reply "accepted", and let a worker do the slow part.
- Service Bus queue: peek-lock. An Azure Service Bus queue hands each message to one receiver. In peek-lock mode the message is locked, not removed. The worker completes it when done, or abandons it so it can be tried again. If the worker crashes, the lock expires and the message comes back.
- Dead-letter queue. A poison message fails every time. After max delivery count attempts (10 by default) Service Bus moves it to the dead-letter queue (DLQ), a sub-queue you read, fix and resubmit. Expired messages can go there too.
- Topics and subscriptions. A topic is a queue with many readers. Each subscription gets its own copy of every message, and filters (SQL or correlation) decide which messages a subscription keeps. One "document uploaded" message can feed indexing, billing and audit.
- Event Grid: something happened. Azure Event Grid pushes events (small facts: "blob created") to handlers. You can publish custom events to a custom topic. Event subscriptions pick the handler, and filters (event type, subject begins/ends with, advanced) cut out the noise.
- Event Grid retries. If the handler is down, Event Grid retries with exponential backoff, by default up to 30 attempts within 24 hours (you can lower both). After that it drops the event, unless you configured dead-lettering to a storage container.
- Functions: triggers and bindings. An Azure Function runs when its trigger fires: HTTP, Service Bus, Event Grid, timer, Cosmos DB and more. Bindings connect inputs and outputs without client code: an HTTP-triggered API can write a message to a queue with an output binding.
- Functions scale with the work. On the Flex Consumption plan a function app adds instances as messages arrive and scales to zero when idle. Premium keeps warm instances to avoid cold starts. Settings live in app settings, and you deploy a zip package or a container.
Build an order intake API with no server and almost no code: an HTTP-triggered function whose output binding drops each order on a Service Bus queue, connected with a managed identity instead of a connection string.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
It works locally but the deployed function can’t find its settings.
😊 THE SOLUTION
Set app settings, use managed identity and deploy a package.
- Missing settings✓ App settings
- Connection strings✓ Identity-based connections
- Cold starts✓ Always-ready instances
Start with a question
It ran fine on my laptop. Why does it break the moment I deploy it?
Moving into a new flat, you bring your furniture, but the electricity, water and Wi-Fi password come with the building. If you assume your old Wi-Fi password still works, nothing connects.
A function app is the same. Your code moves, but the settings live in Azure. local.settings.json stays on your laptop, so in Azure you set app settings. You also pick the building: the hosting plan decides how the app scales, how fast it wakes up and whether it can reach a private network.
Explain it like I’m 10
The technical explanation
Three files, three jobs
| File | Where it lives | What goes in it |
|---|---|---|
function_app.py | Deployed | Your functions, triggers and bindings |
host.json | Deployed | Runtime settings for every function in the app: version, extensionBundle, logging, functionTimeout, trigger tuning |
local.settings.json | Your machine only | Values that become environment variables when you run func start. Never published, kept out of git. |
A small host.json for a Service Bus worker:
{
"version": "2.0",
"extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.*, 5.0.0)" },
"logging": { "applicationInsights": { "samplingSettings": { "isEnabled": true } } },
"extensions": {
"serviceBus": { "maxConcurrentCalls": 8, "autoCompleteMessages": true }
}
}
And the matching local.settings.json, using identity locally too:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"ServiceBusConnection__fullyQualifiedNamespace": "contoso-ai.servicebus.windows.net"
}
}
App settings and identity-based connections
In Azure, every value from Values becomes an app setting, read by your code with os.environ["NAME"]. Changing an app setting restarts the app. Secrets belong in Key Vault, referenced from an app setting like @Microsoft.KeyVault(SecretUri=...).
Better still, skip the secret. When a binding has connection="ServiceBusConnection", the runtime looks for settings that start with that name:
| Setting | Meaning |
|---|---|
ServiceBusConnection | A connection string (has a key in it) |
ServiceBusConnection__fullyQualifiedNamespace = contoso-ai.servicebus.windows.net | Use the app’s managed identity |
AzureWebJobsStorage__accountName = stcontosoai | Host storage over identity instead of a key |
Give the function app’s managed identity the right data role: Azure Service Bus Data Receiver for a trigger, Data Sender for an output binding (or Data Owner for both). If you use a user-assigned identity, also add ServiceBusConnection__credential = managedidentity and ServiceBusConnection__clientId.
az functionapp config appsettings set -g rg-ai -n func-summarise \
--settings ServiceBusConnection__fullyQualifiedNamespace=contoso-ai.servicebus.windows.net
Hosting plans
| Plan | Scaling | Cold start | Network | Notes |
|---|---|---|---|---|
| Flex Consumption | Event-driven, per function, to zero | Optional always-ready instances | VNet integration | Recommended serverless plan. Linux. Pay per execution plus any always-ready instances. Choose instance memory. |
| Premium (Elastic Premium) | Event-driven, never below 1 | Pre-warmed, none | VNet integration | Linux or Windows, deployment slots, longer runs. Billed per core-second while instances run. |
| Dedicated | Manual or autoscale | None (always on) | VNet integration | Runs on an App Service plan you already pay for. |
| Consumption (legacy) | Event-driven, to zero | Yes | No VNet | Older serverless plan. Prefer Flex Consumption for new apps. |
Functions can also run in Azure Container Apps if you ship them as a container image.
Create and deploy
Create a Flex Consumption app (the storage account holds the deployment package and host state):
az functionapp create -g rg-ai -n func-summarise \
--storage-account stcontosoai \
--flexconsumption-location eastus \
--runtime python --runtime-version 3.12 \
--assign-identity '[system]'
Then deploy from the project folder. Core Tools packages the code and, for Python on Linux, runs a remote build that installs requirements.txt in Azure:
func azure functionapp publish func-summarise
Other options: zip deploy (az functionapp deployment source config-zip -g rg-ai -n func-summarise --src app.zip), the Azure Functions extension in VS Code, or a GitHub Actions / Azure Pipelines workflow. Whatever you pick, local.settings.json isn’t sent.
Keep a warm instance for the HTTP functions so the first morning request isn’t slow:
az functionapp scale config always-ready set -g rg-ai -n func-summarise --settings http=1
-
1 Create
az functionapp create with --flexconsumption-location and a managed identity.
-
2 Configure
App settings, including ServiceBusConnection__fullyQualifiedNamespace, plus a data role.
-
3 Deploy
func azure functionapp publish packages the code and builds Python remotely.
-
4 Scale
Instances follow the queue length and drop to zero, apart from any always-ready ones.
Architect level Timeouts, concurrency and what Flex doesn't do
functionTimeout in host.json caps how long a run can take. On Flex Consumption and Premium the default is 30 minutes and you can raise it; the legacy Consumption plan stops at 10 minutes. HTTP responses still have the roughly 230-second load balancer limit, so long AI calls go through a queue.
Flex Consumption scales HTTP functions on concurrency (how many requests one instance handles at once) and queue triggers on backlog. You can tune maxConcurrentCalls in host.json to stop one instance from opening too many model calls and hitting rate limits. Flex Consumption doesn’t support deployment slots, so if you need swap-based releases, use Premium or Dedicated, or deploy a second app and switch traffic in front of it.
Real-world business scenario
Litware Learning (fictional)
- The problem
- An essay-feedback function ran on the legacy Consumption plan with a Service Bus connection string pasted into app settings. Security flagged the key, the function couldn't reach a private model endpoint, and the first essay each morning waited on a cold start.
- What they used
- The team moved to a Flex Consumption app created with az functionapp create --flexconsumption-location, turned on a system-assigned managed identity with Azure Service Bus Data Owner, replaced the key with ServiceBusConnection__fullyQualifiedNamespace, added VNet integration and set one always-ready instance for the http group. GitHub Actions now runs func azure functionapp publish on every merge.
- Why that choice
- No secret is left to leak, the app reaches the private endpoint, and the warm instance removes the morning delay while idle workers still scale to zero.
- The result
- Security closed the finding, feedback starts within a second at 8 a.m., and the monthly bill stayed close to the old Consumption cost.
When to use it and when not to
✓ Use it when…
- Flex Consumption for new serverless function apps, especially ones that need a VNet or fast first responses.
- Identity-based connections whenever the target service supports Microsoft Entra ID.
- host.json for settings that should apply to every function, app settings for values that differ per environment.
✕ Think twice when…
- Committing local.settings.json or pasting keys into code.
- The legacy Consumption plan for new apps that need private networking.
- Flex Consumption when you depend on deployment slots or Windows-only features. Use Premium or Dedicated.
↔ Alternatives to consider
- Premium plan for always-warm apps with deployment slots.
- Dedicated (App Service) plan when you already have spare App Service capacity.
- Azure Container Apps when you want to ship functions as a container image.
Test yourself with exercises
5 original practice questions in the AI-200 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Your function works locally but fails in Azure with "setting not found". Why?
Model answer
Because local.settings.json only exists on my laptop. Core Tools reads it, but it's never published. In Azure every setting has to be added as an app setting on the function app, through the portal, az functionapp config appsettings set or infrastructure code.
Intermediate How do you connect a Service Bus trigger to the namespace without a connection string?
Model answer
Turn on a managed identity for the function app, give it Azure Service Bus Data Receiver on the queue (or Data Owner if it also sends), and replace the ServiceBusConnection setting with ServiceBusConnection__fullyQualifiedNamespace set to mynamespace.servicebus.windows.net. The decorator still says connection="ServiceBusConnection"; the runtime sees the suffix and uses the identity.
Experienced developer Which hosting plan would you choose for a queue-driven AI worker that needs a VNet and fast cold starts?
Model answer
Flex Consumption. It supports virtual network integration, scales per function based on queue length, scales to zero when idle and lets me set one or two always-ready instances for the trigger that matters. I'd pick Premium only if I needed something Flex doesn't offer, like deployment slots or Windows, and Dedicated if I already pay for an App Service plan with spare room.
Scenario Users complain the first summary request each morning takes several seconds longer. What would you change?
Model answer
That's a cold start after scaling to zero overnight. On Flex Consumption I'd set always-ready instances for the http group, for example az functionapp scale config always-ready set with http=1. I pay for that warm instance, so I'd keep the number small and watch the cost.
Quick revision
Key points
- host.json = runtime settings for all functions, deployed with the code. local.settings.json = local only, never published.
- In Azure, settings are app settings (environment variables). Use Key Vault references for secrets.
- Identity-based connections - <name>__fullyQualifiedNamespace plus a data role on the managed identity.
- Plans - Flex Consumption (recommended serverless), Premium (always warm, slots), Dedicated (App Service plan), Consumption (legacy).
- Deploy with func azure functionapp publish <app>, zip deploy or CI/CD. Python builds remotely on Linux.
Important terminology
- Function app
- The Azure resource that hosts, scales and deploys a group of functions together.
- host.json
- A project file with runtime settings for every function in the app, such as logging, timeouts and trigger tuning.
- local.settings.json
- A local-only file holding app settings for Core Tools. It isn't published and shouldn't go into source control.
- App settings
- Name-value pairs on the function app in Azure, exposed to your code as environment variables.
- Flex Consumption plan
- The recommended serverless hosting plan for Functions, with per-function scaling, scale to zero, always-ready instances and VNet support.
- Always-ready instances
- Instances a Flex Consumption app keeps running for chosen trigger groups or functions, to avoid cold starts.
- Identity-based connection
- A trigger or binding connection that uses a managed identity, set with a __fullyQualifiedNamespace or similar suffix instead of a connection string.
Common mistakes
- Expecting local.settings.json to be deployed.
- Pasting a connection string into function code instead of an app setting.
- Choosing the legacy Consumption plan for a new app that needs a VNet.
Exam tips
- "Serverless, scale to zero, VNet, avoid cold starts" = Flex Consumption with always-ready instances.
- "No secrets for the Service Bus trigger" = managed identity + __fullyQualifiedNamespace.
- "Change a setting for every function in the app" = host.json.
Five quick revision questions
-
1.Which file is never deployed to Azure?Show
local.settings.json.
-
2.Which file sets runtime behaviour for all functions?Show
host.json.
-
3.Which suffix makes a Service Bus connection identity-based?Show
__fullyQualifiedNamespace.
-
4.Which az functionapp create option makes a Flex Consumption app?Show
--flexconsumption-location.
-
5.Which Core Tools command deploys a project?Show
func azure functionapp publish <app-name>.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Azure Key Vault: Retrieve and Rotate Secrets
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.