Lesson 4 of 4 Serverless APIs with Azure Functions

Configuring and Deploying Function Apps

This lesson explains the hosting plans, how to create a Flex Consumption app, app settings and host.json, and the deployment methods.

Learning outcomes

After completing this lesson, you will be able to:

  • Compare the Functions hosting plans.
  • Describe the features of Flex Consumption.
  • Distinguish app settings from host.json.
  • Describe the deployment methods for Python apps.

Hosting plans

The hosting plan decides how a function app scales, what it costs and which features it has. The Flex Consumption plan is Microsoft's recommended serverless plan for new apps, and the original Consumption plan is now a legacy option: Linux Consumption gets no new features or language versions and retires on 30 September 2028, so Python apps, which require Linux, should use Flex Consumption or another plan.

Flex Consumption
BillingPer execution and memory, plus always ready instances
ScalePer function, up to 1,000 instances
Cold startsReduced; always ready instances avoid them
ContainersNo
Choose when New serverless apps, including virtual network access
Premium
BillingPer core-second of warm and active instances
ScaleEvent-driven, up to 100
Cold startsAvoided with warm instances
ContainersLinux
Choose when Always-warm, steady workloads with custom images
Dedicated (App Service plan)
BillingPlan instances, always on
ScaleManual or autoscale
Cold startsNone with Always On
ContainersLinux
Choose when Existing App Service capacity or predictable cost
Container Apps
BillingContainer Apps plan billing
ScaleEvent-driven replicas
Cold startsAvoided when minimum replicas is above zero
ContainersYes
Choose when Functions alongside other container apps

Flex Consumption instances have 512 MB, 2,048 MB or 4,096 MB of memory, support virtual network integration and private endpoints, and can keep always ready instances warm for chosen function groups. HTTP functions scale together as one group, and other triggers scale per function. The default function timeout is 30 minutes on every plan except legacy Consumption (5 minutes, maximum 10).

The following diagram maps each requirement of a function app to the Flex Consumption feature that meets it.

How Flex Consumption meets each requirement. Virtual network integration reaches the PostgreSQL private endpoint, scaling from zero keeps idle cost low, always ready instances for the HTTP function group remove the morning cold start, and GitHub Actions with workload identity federation deploys without a stored secret.
The requirements are typical examples.
Sort into groups

Which hosting plan?

Exam skills 3.2.2

Choose the Functions hosting plan for each situation.

Log in to try this activity Interactive activities are free with an account.

Creating a Flex Consumption app

A function app needs a storage account for the host's internal data and, on Flex Consumption, a blob container to hold the deployment package. The following commands create both and the app, with a system-assigned identity and an Application Insights resource created automatically.

az storage account create --resource-group RG --name STORAGE --location LOCATION --sku Standard_LRS
az functionapp create --resource-group RG --name APP --storage-account STORAGE \
  --flexconsumption-location LOCATION --runtime python --runtime-version 3.12 \
  --instance-memory 2048 --assign-identity "[system]"
Select all that apply

Creating a Flex Consumption app

Exam skills 3.2.2

Identify what a new Flex Consumption function app needs or gets.

Log in to try this activity Interactive activities are free with an account.

App settings and host.json

App settings are environment variables for the host and the code. Important built-in settings include AzureWebJobsStorage (or its identity-based form AzureWebJobsStorage__accountName), APPLICATIONINSIGHTS_CONNECTION_STRING for monitoring, and the connection prefixes used by triggers and bindings. Application settings such as a model deployment name live here too, and secrets are referenced from Key Vault with @Microsoft.KeyVault(...). Changing settings restarts the app.

host.json configures the host for every function in the app. Common settings include functionTimeout, logging levels and sampling, the extension bundle version, and per-extension options such as Service Bus maxConcurrentCalls or the HTTP routePrefix.

{
  "version": "2.0",
  "functionTimeout": "00:10:00",
  "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.*, 5.0.0)" },
  "extensions": {
    "serviceBus": { "maxConcurrentCalls": 8 },
    "http": { "routePrefix": "api" }
  },
  "logging": { "logLevel": { "default": "Information" } }
}
Sort into groups

App setting or host.json?

Exam skills 3.2.2

Decide where each setting is configured.

Log in to try this activity Interactive activities are free with an account.

Deployment methods

Code reaches a function app as a package: the project files plus, for Python, the packages in requirements.txt, which are installed by a remote build on the platform so that compiled dependencies match Linux. Several tools produce and deploy the package.

  • func azure functionapp publish APP from Core Tools builds and deploys the current project.
  • Zip deployment, for example az functionapp deployment source config-zip --src app.zip --build-remote true, deploys a prepared package.
  • One deploy is the deployment mechanism of Flex Consumption: the package is uploaded to the app's deployment storage container, which the tools above use automatically.
  • CI/CD pipelines use the Azure Functions action in GitHub Actions or the Azure Functions task in Azure Pipelines, authenticating with workload identity federation.

Deployment slots, which allow staging and swap, are available on Premium (three slots) and Dedicated plans but not on Flex Consumption; Flex Consumption apps achieve safe releases with separate staging apps or rolling updates managed by the platform. Premium and Dedicated plans can also run a function app from a custom Linux container image.

Scenario questions

Deploying function apps

Exam skills 3.2.2

Choose the deployment approach that fits each requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing a plan and a deployment approach

A new Python function app handles Service Bus messages and a few HTTP endpoints. It must reach a PostgreSQL server through a private endpoint, cost little when idle, and respond to the first HTTP request of the morning without a long cold start. Deployments come from GitHub without stored secrets.

Flex Consumption fits: it is serverless, supports virtual network integration to reach the private endpoint, and one or more always ready instances for the HTTP function group remove the morning cold start while other functions scale from zero. Deployment uses GitHub Actions with the Azure Functions action and workload identity federation, so no publish profile or secret is stored.

Linux Consumption is legacy and has no virtual network integration. Premium also works but keeps at least one instance billed continuously for the whole app. A publish profile stored as a GitHub secret contradicts the no-secrets requirement.

Check yourself

Which Functions hosting plan is recommended for new serverless Python apps, and why is Linux Consumption not a good choice?

Show answer

Flex Consumption. Linux Consumption is legacy, gets no new features or language versions, and retires on 30 September 2028.

Exam Tips

Remember for the exam

  • Flex Consumption is recommended for new serverless apps; Linux Consumption is legacy and retires 30 September 2028.
  • Flex Consumption: up to 1,000 instances, 512/2,048/4,096 MB, virtual network integration, always ready instances, no slots.
  • host.json holds functionTimeout, extension settings and logging for the whole app.
  • Python packages are installed by remote build; deploy with func publish, zip deploy or CI/CD.