Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes reliability support in Azure Functions, and covers both intra-regional resiliency with availability zones and cross-region recovery and business continuity. For a more detailed overview of reliability principles in Azure, see Azure reliability.
Availability zones support for Azure Functions depends on your Functions hosting plan:
Hosting plan | Support level | For more information... |
---|---|---|
Flex Consumption plan | Preview | Select Flex Consumption at the top of this article. |
Elastic Premium plan | GA | Select Premium at the top of this article. |
Dedicated (App Service) plan | GA | See Reliability in Azure App Service. |
Consumption plan | n/a | Not supported by the Consumption plan. |
Availability zones are physically separate groups of datacenters within each Azure region. When one zone fails, services can fail over to one of the remaining zones.
For more information, see What are availability zones?.
Azure Functions supports a zone-redundant deployment.
Availability zones support
Important
Support for availability zones when hosting your app in a Flex Consumption plan is currently in preview.
When you configure Flex Consumption plan apps as zone redundant, the platform automatically spreads instances of your function app across the zones in the selected region, with different rules for always-ready versus on-demand instances.
When zone redundancy is enabled in a Flex Consumption plan, instance spreading is determined inside the following rules:
- Always-ready instances are distributed across at least two zones in a round-robin fashion.
- On-demand instances, which are created as a result of event source volumes as the app scales beyond always-ready, are distributed across availability zones on a best effort basis. This means that for on-demand instances, faster scale-out is given preference over even distribution across availability zones. The platform attempts to even-out distribution over time.
- To ensure zone resiliency with availability zones, the platform automatically maintains at least two always-ready instances for each per-function scaling function or group, regardless of the always-ready configuration for the app. Any instances created by the platform are platform-managed, billed as always-ready instances, and don't change the always-ready configuration settings.
When you configure Elastic Premium function app plans as zone redundant, the platform automatically spreads the function app instances across the zones in the selected region.
Instance spreading with a zone-redundant deployment is determined inside the following rules, even as the app scales in and out:
- The minimum function app instance count is three.
- When you specify a capacity larger than the number of zones, the instances are spread evenly only when the capacity is a multiple of the number of zones.
- For a capacity value more than Number of Zones * Number of instances, extra instances are spread across the remaining zones.
Important
Azure Functions can run on the Azure App Service platform. In the App Service platform, plans that host Premium plan function apps are referred to as Elastic Premium plans, with SKU names like EP1
. If you choose to run your function app on a Premium plan, make sure to create a plan with an SKU name that starts with E
, such as EP1
. App Service plan SKU names that start with P
, such as P1V2
(Premium V2 Small plan), are Dedicated hosting plans. Because they're Dedicated and not Elastic Premium, plans with SKU names starting with P
don't scale dynamically and can increase your costs.
Regional availability
Currently, not all regions support zone redundancy for Flex Consumption plans. You can use the Azure CLI to view the regions that do support it:
If you haven't done so already, install and sign in to Azure using the Azure CLI:
az login
The
az login
command signs you into your Azure account.Use this
az functionapp list-flexconsumption-locations
command with the--zone-redundant=true
option to return a list of regions that currently support zone-redundant Flex Consumption plans:az functionapp list-flexconsumption-locations --zone-redundant=true --query "sort_by(@, &name)[].{Region:name}" -o table
When you create a Flex Consumption app in the Azure portal, the Zone redundancy
section of the Basics page is enabled when your chosen region supports it.
Zone-redundant Premium plans are available in these regions:
Americas | Europe | Middle East | Africa | Asia Pacific |
---|---|---|---|---|
Brazil South | France Central | Israel Central | South Africa North | Australia East |
Canada Central | Germany West Central | Qatar Central | Central India | |
Central US | Italy North | UAE North | China North 3 | |
East US | North Europe | East Asia | ||
East US 2 | Norway East | Japan East | ||
South Central US | Sweden Central | Southeast Asia | ||
West US 2 | Switzerland North | |||
West US 3 | UK South | |||
West Europe |
Prerequisites
Availability zone support is a property of the Flex Consumption plan. Here are current considerations for using availability zones:
- You can enable availability zones in the plan during app creation.
- You can enable or disable availability zones by updating plan resource settings.
- You must use a zone redundant storage account (ZRS) for your function app's default host storage account. If you use a different type of storage account, your app might behave unexpectedly during a zonal outage.
- Must be hosted on a Flex Consumption plan.
Availability zone support is a property of the Premium plan. Here are current considerations for availability zones:
- You can only enable availability zones in the plan when you create your app. You can't convert an existing Premium plan to use availability zones.
- You must use a zone redundant storage account (ZRS) for your function app's default host storage account. If you use a different type of storage account, your app might behave unexpectedly during a zonal outage.
- Both Windows and Linux are supported.
- Function apps hosted on a Premium plan must have a minimum of three always ready instances.
- The platform enforces this minimum count behind the scenes if you specify an instance count fewer than three.
- If you aren't using Premium plan or a scale unit that supports availability zones, are in an unsupported region, or are unsure, see the migration guidance.
Pricing
There's no separate meter associated with enabling availability zones. Pricing for instances used for a zone-redundant Flex Consumption app is the same as a single zone Flex Consumption app. To learn more, see Billing.
When you enable availability zones in an app with always-ready instance configuration of fewer than two instances for each per-function scaling function or group, the platform automatically creates two instances of the always-ready type for each per-function scaling function or group. These new instances are also billed as always-ready instances.
There's no extra cost associated with enabling availability zones. Pricing for a zone-redundant Premium App Service plan is the same as a single zone Premium plan. For each App Service plan you use, you're charged based on the SKU you choose, the capacity you specify, and any instances you scale to based on your autoscale criteria. If you enable availability zones on a plan with fewer than three instances, the platform enforces a minimum instance count of three for that App Service plan, and you're charged for all three instances.
Create a function app in a zone-redundant plan
There are currently multiple ways to deploy a zone-redundant Flex Consumption app.
In the Azure portal, go to the Create Function App page. For more information about creating a function app in the portal, see Create a function app.
Select Flex Consumption and then select the Select button.
On the Create Function App (Flex Consumption) page, on the Basics tab, enter the settings for your function app. Pay special attention to the settings in the following table (also highlighted in the following screenshot), which have specific requirements for zone redundancy.
Setting Suggested value Notes for zone redundancy Region Your preferred supported region The region in which your Flex Consumption plan is created. You must select a region that supports availability zones. See the region availability list. Zone redundancy Enabled This setting specifies whether your app is zone redundant. You can only select Enabled
when you've chosen a region that supports zone redundancy.On the Storage tab, enter the settings for your function app storage account. Pay special attention to the setting in the following table, which has specific requirements for zone redundancy.
Setting Suggested value Notes for zone redundancy Storage account A zone-redundant storage account As described in the prerequisites section, we strongly recommend using a zone-redundant storage account for your zone-redundant function app. For the rest of the function app creation process, create your function app as normal. There are no settings in the rest of the creation process that affect zone redundancy.
After the zone-redundant plan is created and deployed, the Flex Consumption function app hosted on your new plan is considered zone-redundant.
Update a Flex Consumption plan to be zone-redundant
Changing the zone redundancy of your app requires a restart, which causes downtime in your app.
Before updating your Flex Consumption plan to be zone-redundant, you should update the default host storage account to also be zone redundant. If you use a separate storage account for the app's deployment container, you should update it to be zone redundant as well.
Use these steps to prepare your storage accounts for the change:
- Review Storage Considerations.
- Create or identify a zone-redundant storage account to be the default host storage account for the app.
- Update the storage related application settings of the app, like
AzureWebJobsStorage
, to reference the zone redundant storage account. See Work with application settings. - Update the deployment storage account for the app, which can be the same or different as the storage account associated with the app. See Configure deployment settings.
After the storage accounts used by your app are updated, you can update the Flex Consumption plan to be zone-redundant using Bicep or ARM templates. The Azure portal currently doesn't support making zone redundancy updates to the plan.
Not currently supported.
There are currently two ways to deploy a zone-redundant Premium plan and function app. You can use either the Azure portal or an ARM template.
In the Azure portal, go to the Create Function App page. For more information about creating a function app in the portal, see Create a function app.
Select Functions Premium and then select the Select button.
On the Create Function App (Functions Premium) page, on the Basics tab, enter the settings for your function app. Pay special attention to the settings in the following table (also highlighted in the following screenshot), which have specific requirements for zone redundancy.
Setting Suggested value Notes for zone redundancy Region Your preferred supported region The region in which your Elastic Premium plan is created. You must pick a region that supports availability zones. See the region availability list. Pricing plan One of the Elastic Premium plans. For more information, see Available instance SKUs. This article describes how to create a zone redundant app in a Premium plan. Zone redundancy isn't currently available in Consumption plans. For information on zone redundancy on App Service plans, see Reliability in Azure App Service. Zone redundancy Enabled This setting specifies whether your app is zone redundant. You won't be able to select Enabled
unless you have chosen a region that supports zone redundancy, as described previously.On the Storage tab, enter the settings for your function app storage account. Pay special attention to the setting in the following table, which has specific requirements for zone redundancy.
Setting Suggested value Notes for zone redundancy Storage account A zone-redundant storage account As described in the prerequisites section, we strongly recommend using a zone-redundant storage account for your zone-redundant function app. For the rest of the function app creation process, create your function app as normal. There are no settings in the rest of the creation process that affect zone redundancy.
After the zone-redundant plan is created and deployed, any function app hosted on your new plan is considered zone-redundant.
Availability zone migration
You can't currently change the availability zone support of an Elastic Premium plan for an existing function app. For information on how to migrate the public multitenant Premium plan from nonavailability zone to availability zone support, see Migrate App Service to availability zone support.
Zone down experience
All available function app instances of zone-redundant Flex Consumption plan apps are enabled and processing events. Flex Consumption apps continue to run even when other zones in the same region suffer an outage. However, it's possible that nonruntime behaviors might be impacted as a result of an outage in other availability zones. Standard function app behaviors that can affect availability include:
- Scaling
- App creation
- Configuration changes
- Deployments
Zone redundancy for Flex Consumption plans only guarantees continued uptime for deployed applications that are running.
When a zone goes down, Functions detects lost instances and automatically attempts to locate or create replacement instances, as needed, in the available zones. During zonal outage, the platform tries to restore balance on the available zones remaining.
All available function app instances of zone-redundant function apps are enabled and processing events. When a zone goes down, Functions detect lost instances and automatically attempts to find new replacement instances if needed. Elastic scale behavior still applies. However, in a zone-down scenario there's no guarantee that requests for more instances can succeed, since back-filling lost instances occurs on a best-effort basis. Applications that are deployed in an availability zone enabled Premium plan continue to run even when other zones in the same region suffer an outage. However, it's possible that nonruntime behaviors could still be impacted from an outage in other availability zones. These impacted behaviors can include Premium plan scaling, application creation, application configuration, and application publishing. Zone redundancy for Premium plans only guarantees continued uptime for deployed applications.
When Functions allocates instances to a zone redundant Premium plan, it uses best effort zone balancing offered by the underlying Azure Virtual Machine Scale Sets. A Premium plan is considered balanced when each zone has either the same number of virtual machines in all of the other zones used by the Premium plan, plus-or-minus one virtual machine.
Cross-region disaster recovery and business continuity
Disaster recovery (DR) refers to practices that organizations use to recover from high-impact events, such as natural disasters or failed deployments that result in downtime and data loss. Regardless of the cause, the best remedy for a disaster is a well-defined and tested DR plan and an application design that actively supports DR. Before you start creating your disaster recovery plan, see Recommendations for designing a disaster recovery strategy.
For DR, Microsoft uses the shared responsibility model. In this model, Microsoft ensures that the baseline infrastructure and platform services are available. However, many Azure services don't automatically replicate data or fall back from a failed region to cross-replicate to another enabled region. For those services, you're responsible for setting up a disaster recovery plan that works for your workload. Most services that run on Azure platform as a service (PaaS) offerings provide features and guidance to support DR. You can use service-specific features to support fast recovery to help develop your DR plan.
This section explains some of the strategies that you can use to deploy a function app to allow for disaster recovery.
For disaster recovery for Durable Functions, see Disaster recovery and geo-distribution in Azure Durable Functions.
Multi-region disaster recovery
Because there's no built-in redundancy available, functions run in a function app in a specific Azure region. To avoid loss of execution during outages, you can redundantly deploy the same functions to function apps in multiple regions. To learn more about multi-region deployments, see the guidance in Highly available multi-region web application.
When you run the same function code in multiple regions, there are two patterns to consider, active-active and active-passive.
Active-active pattern for HTTP trigger functions
With an active-active pattern, functions in both regions are actively running and processing events, either in a duplicate manner or in rotation. You should use an active-active pattern in combination with Azure Front Door for your critical HTTP triggered functions, which can route and round-robin HTTP requests between functions running in multiple regions. Front door can also periodically check the health of each endpoint. When a function in one region stops responding to health checks, Azure Front Door takes it out of rotation, and only forwards traffic to the remaining healthy functions.
For an example, see the sample on how to implement the geode pattern by deploying the API to geodes in distributed Azure regions..
Active-passive pattern for non-HTTPS trigger functions
It's recommended that you use active-passive pattern for your event-driven, non-HTTP triggered functions, such as Service Bus and Event Hubs triggered functions.
To create redundancy for non-HTTP trigger functions, use an active-passive pattern. With an active-passive pattern, functions run actively in the region that's receiving events; while the same functions in a second region remain idle. The active-passive pattern provides a way for only a single function to process each message while providing a mechanism to fail over to the secondary region in a disaster. Function apps work with the failover behaviors of the partner services, such as Azure Service Bus geo-recovery and Azure Event Hubs geo-recovery.
Consider an example topology using an Azure Event Hubs trigger. In this case, the active/passive pattern requires involve the following components:
- Azure Event Hubs deployed to both a primary and secondary region.
- Geo-disaster enabled to pair the primary and secondary event hubs. This also creates an alias you can use to connect to event hubs and switch from primary to secondary without changing the connection info.
- Function apps are deployed to both the primary and secondary (failover) region, with the app in the secondary region essentially being idle because messages aren't being sent there.
- Function app triggers on the direct (nonalias) connection string for its respective event hub.
- Publishers to the event hub should publish to the alias connection string.
Before failover, publishers sending to the shared alias route to the primary event hub. The primary function app is listening exclusively to the primary event hub. The secondary function app is passive and idle. As soon as failover is initiated, publishers sending to the shared alias are routed to the secondary event hub. The secondary function app now becomes active and starts triggering automatically. Effective failover to a secondary region can be driven entirely from the event hub, with the functions becoming active only when the respective event hub is active.
Read more on information and considerations for failover with Service Bus and Event Hubs.
Active-active pattern for non-HTTPS trigger functions
While you're encouraged to use the active-passive pattern for non-HTTPS trigger functions, you can still create active-active deployments for non-HTTP triggered functions. Before you implement this pattern, you must consider how the two active regions interact or coordinate with one another.
For example, consider having the same Service Bus triggered function code deployed to two regions but triggering on the same Service Bus queue. In this case, both functions act as competing consumers on dequeueing the single queue. While each message can only be processed by one of the two app instances, it also means there's still a single point of failure, which is the single Service Bus instance.
You might instead deploy two Service Bus queues, with one in a primary region, one in a secondary region. In this case, you could have two function apps, with each pointed to the Service Bus queue active in their region. The challenge with this topology is how the queue messages are distributed between the two regions. Often, this means that each publisher attempts to publish a message to both regions, and each message is processed by both active function apps. While this creates the desired active/active pattern, it also creates other challenges around duplication of compute and when or how data is consolidated.