Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 24 of 28
❮Prev Next❯

Configure and Deploy Function Apps

Module 3: Messaging & Functions ⏱ 11 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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.

    Simulate it » No Azure account needed

    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.

    Azure portal: App settings and package deployment for a function app Set app settings and deploy a package.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. Open Settings → Environment variables. The __fullyQualifiedNamespace suffix tells the Service Bus trigger to use the managed identity.
    2. Add the model deployment name your code reads with os.environ.
    3. Select Apply and confirm. The app restarts and picks up the new value; no redeploy needed.
    4. Now ship the code. Zip the project and deploy the package. Flex Consumption stores it in a blob container and runs it from there.
    5. For every push, Deployment Center can set up a GitHub Actions workflow that does the same deploy.
    6. 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.

    😟 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
    🛠️ Solved with: Function app deployment

    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

    FileWhere it livesWhat goes in it
    function_app.pyDeployedYour functions, triggers and bindings
    host.jsonDeployedRuntime settings for every function in the app: version, extensionBundle, logging, functionTimeout, trigger tuning
    local.settings.jsonYour machine onlyValues 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:

    SettingMeaning
    ServiceBusConnectionA connection string (has a key in it)
    ServiceBusConnection__fullyQualifiedNamespace = contoso-ai.servicebus.windows.netUse the app’s managed identity
    AzureWebJobsStorage__accountName = stcontosoaiHost 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

    PlanScalingCold startNetworkNotes
    Flex ConsumptionEvent-driven, per function, to zeroOptional always-ready instancesVNet integrationRecommended serverless plan. Linux. Pay per execution plus any always-ready instances. Choose instance memory.
    Premium (Elastic Premium)Event-driven, never below 1Pre-warmed, noneVNet integrationLinux or Windows, deployment slots, longer runs. Billed per core-second while instances run.
    DedicatedManual or autoscaleNone (always on)VNet integrationRuns on an App Service plan you already pay for.
    Consumption (legacy)Event-driven, to zeroYesNo VNetOlder 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. 1 Create

      az functionapp create with --flexconsumption-location and a managed identity.

    2. 2 Configure

      App settings, including ServiceBusConnection__fullyQualifiedNamespace, plus a data role.

    3. 3 Deploy

      func azure functionapp publish packages the code and builds Python remotely.

    4. 4 Scale

      Instances follow the queue length and drop to zero, apart from any always-ready ones.

    From laptop to running function app
    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

    Education technology

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    A Python function app runs correctly on a developer workstation by using Azure Functions Core Tools. After deployment to Azure, the function fails because an environment variable named MODEL_DEPLOYMENT is not found. The value is defined in local.settings.json. What should you do?

    Question 2

    Question 2 of 5

    A function uses @app.service_bus_queue_trigger(..., connection="ServiceBusConnection"). The function app has a system-assigned managed identity that has the Azure Service Bus Data Receiver role on the queue. Connection strings must not be used.

    Which application setting should you add?

    Question 3

    Question 3 of 5

    You need to host a new Python function app that scales to zero when idle, integrates with a virtual network, and can avoid cold starts for HTTP functions. Costs must be based on usage where possible. Which hosting option should you choose?

    Question 4

    Question 4 of 5

    You must change the maximum number of Service Bus messages that each instance of a function app processes concurrently. The change must apply to all Service Bus-triggered functions in the app. Where should you make the change?

    Question 5

    Question 5 of 5 · Select 2

    You are deploying a Python function project to a new function app in the Flex Consumption plan by using command-line tools. Which TWO commands should you use?

    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. 1.Which file is never deployed to Azure?Show

      local.settings.json.

    2. 2.Which file sets runtime behaviour for all functions?Show

      host.json.

    3. 3.Which suffix makes a Service Bus connection identity-based?Show

      __fullyQualifiedNamespace.

    4. 4.Which az functionapp create option makes a Flex Consumption app?Show

      --flexconsumption-location.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.