Skip to content

Commit 2b9d401

Browse files
committed
Adding post-create AZ for EP plan, and how to check instances
1 parent f35afb2 commit 2b9d401

1 file changed

Lines changed: 198 additions & 15 deletions

File tree

articles/azure-functions/functions-zone-redundancy.md

Lines changed: 198 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Availability zone configuration for Azure Functions depends on your [Functions h
3535
> [!IMPORTANT]
3636
> Before configuring zone redundancy, review the requirements and details listed in [Reliability in Azure Functions - Resilience to availability zone failures](/azure/reliability/reliability-functions?pivots=premium#resilience-to-availability-zone-failures).
3737
>
38-
> 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.
38+
> You can enable or disable availability zones on existing Elastic Premium plans using the Azure CLI. See [Enable zone redundancy on an existing plan](#enable-zone-redundancy-on-an-existing-plan) for important details about Elastic Premium-specific capacity behavior.
3939
4040
::: zone-end
4141

@@ -253,7 +253,7 @@ You can use a [Bicep file](/azure/azure-resource-manager/bicep/quickstart-create
253253
The only properties to be aware of while creating a zone-redundant hosting plan are the `zoneRedundant` property and the plan's instance count (`capacity`) fields. The `zoneRedundant` property must be set to `true` and the `capacity` property should be set based on the workload requirement, but not less than `3`. Choosing the right capacity varies based on several factors and high availability / fault tolerance strategies. A good rule of thumb is to specify sufficient instances for the application to ensure that losing one zone instance leaves sufficient capacity to handle expected load.
254254
255255
> [!IMPORTANT]
256-
> Azure Functions apps hosted on an Elastic Premium, zone-redundant plan must have a minimum [always ready instance](/azure/azure-functions/functions-premium-plan#always-ready-instances) count of 3. This minimum ensures that a zone-redundant function app always has enough instances to satisfy at least one worker per zone.
256+
> Azure Functions apps hosted on an Elastic Premium, zone-redundant plan must have a minimum [always ready instance](/azure/azure-functions/functions-premium-plan#always-ready-instances) count of 2. This minimum ensures that a zone-redundant function app always has enough instances to satisfy at least one worker per zone.
257257
258258
Following is a Bicep template snippet for a zone-redundant, Premium plan. It shows the `zoneRedundant` field and the `capacity` specification.
259259
@@ -293,7 +293,7 @@ You can use an [ARM template](/azure/azure-resource-manager/templates/quickstart
293293
The only properties to be aware of while creating a zone-redundant hosting plan are the `zoneRedundant` property and the plan's instance count (`capacity`) fields. The `zoneRedundant` property must be set to `true` and the `capacity` property should be set based on the workload requirement, but not less than `3`. Choosing the right capacity varies based on several factors and high availability / fault tolerance strategies. A good rule of thumb is to specify sufficient instances for the application to ensure that losing one zone instance leaves sufficient capacity to handle expected load.
294294

295295
> [!IMPORTANT]
296-
> Azure Functions apps hosted on an Elastic Premium, zone-redundant plan must have a minimum [always ready instance](/azure/azure-functions/functions-premium-plan#always-ready-instances) count of 3. This minimum ensures that a zone-redundant function app always has enough instances to satisfy at least one worker per zone.
296+
> Azure Functions apps hosted on an Elastic Premium, zone-redundant plan must have a minimum [always ready instance](/azure/azure-functions/functions-premium-plan#always-ready-instances) count of 2. This minimum ensures that a zone-redundant function app always has enough instances to satisfy at least one worker per zone.
297297
298298
Following is an ARM template snippet for a zone-redundant, Premium plan. It shows the `zoneRedundant` field and the `capacity` specification.
299299

@@ -446,24 +446,207 @@ In this template, replace `<YOUR_PLAN_NAME>` and `<YOUR_REGION_NAME>` with the n
446446

447447
::: zone pivot="premium-plan"
448448

449-
You can't change the availability zone support of an existing Elastic Premium plan. Instead, you need to migrate to a new zone-redundant plan.
449+
You can enable or disable zone redundancy on existing Elastic Premium plans using the Azure CLI. The `zoneRedundant` property is mutable for Elastic Premium plans, allowing you to toggle availability zone support without creating a new plan.
450450

451-
### Downtime
451+
> [!IMPORTANT]
452+
> Elastic Premium plans capacity behavior differs from Dedicated (App Service) plans. In Elastic Premium, the plan's instance count (`sku.capacity`) is **derived from the app level**, not set directly on the plan. Each function app in the plan has a `minimumElasticInstanceCount` property (always-ready instances), and the control plane automatically sets the plan's `sku.capacity` to the **highest `minimumElasticInstanceCount` across all apps** in the plan.
453+
>
454+
> When enabling zone redundancy, you must update **both** the plan-level `zoneRedundant` property to `true` and `sku.capacity` to `2` **and** the app-level `minimumElasticInstanceCount` to at least 2 on each function app that you want to be zone redundant. Setting in the plan update command alone does not enforce a minimum of 2 instances.
455+
456+
#### [Azure portal](#tab/azure-portal)
457+
458+
Portal support for toggling availability zone redundancy on existing Elastic Premium plans is not yet available. Use the Azure CLI tab for the current supported workflow.
459+
460+
#### [Azure CLI](#tab/azure-cli)
461+
462+
Follow these steps to enable zone redundancy on an existing Elastic Premium plan:
463+
464+
1. Enable zone redundancy on the plan:
465+
466+
```azurecli
467+
az appservice plan update \
468+
--resource-group <RESOURCE_GROUP> \
469+
--name <PLAN_NAME> \
470+
--set zoneRedundant=true sku.capacity=2
471+
```
472+
473+
> [!NOTE]
474+
> The `sku.capacity=2` parameter in this command sets the intended minimum, but it is not enforced until you complete step 2.
475+
476+
1. Update always-ready instances to at least 2 for each function app that needs to be zone zone redundant in the plan:
477+
478+
```azurecli
479+
az functionapp update \
480+
--resource-group <RESOURCE_GROUP> \
481+
--name <APP_NAME> \
482+
--set siteConfig.minimumElasticInstanceCount=2
483+
```
484+
485+
The plan's actual `sku.capacity` will update to reflect the highest `minimumElasticInstanceCount` across all apps.
486+
487+
To disable zone redundancy on an existing plan:
488+
489+
```azurecli
490+
az appservice plan update \
491+
--resource-group <RESOURCE_GROUP> \
492+
--name <PLAN_NAME> \
493+
--set zoneRedundant=false
494+
```
495+
496+
After disabling zone redundancy, you can optionally reduce `minimumElasticInstanceCount` back to 1 on your function apps if desired.
497+
498+
#### [Bicep template](#tab/bicep)
499+
500+
You can update an existing Elastic Premium plan to be zone-redundant using Bicep templates. The following example shows how to enable zone redundancy:
501+
502+
```bicep
503+
resource EPFuncPlan 'Microsoft.Web/serverfarms@2024-04-01' existing = {
504+
name: '<YOUR_PLAN_NAME>'
505+
}
506+
507+
resource EPFuncPlanUpdate 'Microsoft.Web/serverfarms@2024-04-01' = {
508+
name: EPFuncPlan.name
509+
location: EPFuncPlan.location
510+
sku: {
511+
name: 'EP1'
512+
tier: 'ElasticPremium'
513+
size: 'EP1'
514+
family: 'EP'
515+
capacity: 2
516+
}
517+
kind: 'elastic'
518+
properties: {
519+
perSiteScaling: false
520+
elasticScaleEnabled: true
521+
maximumElasticWorkerCount: 20
522+
isSpot: false
523+
reserved: false
524+
isXenon: false
525+
hyperV: false
526+
targetWorkerCount: 0
527+
targetWorkerSizeId: 0
528+
zoneRedundant: true
529+
}
530+
}
531+
532+
resource FunctionApp 'Microsoft.Web/sites@2024-04-01' = {
533+
name: '<YOUR_APP_NAME>'
534+
location: EPFuncPlan.location
535+
kind: 'functionapp'
536+
properties: {
537+
serverFarmId: EPFuncPlan.id
538+
siteConfig: {
539+
minimumElasticInstanceCount: 2
540+
}
541+
}
542+
}
543+
```
544+
545+
> [!NOTE]
546+
> Remember to update the `minimumElasticInstanceCount` property to at least 2 on all function apps in the plan to ensure zone redundancy requirements are met.
547+
548+
#### [ARM template](#tab/arm-template)
452549

453-
The downtime required for this migration depends on how you redirect traffic during the migration to your new availability zone-enabled function app:
550+
You can update an existing Elastic Premium plan to be zone-redundant using ARM templates. The following example shows how to enable zone redundancy:
454551

455-
- Consider HTTP-based functions that use an [Application Gateway](/azure/app-service/networking/app-gateway-with-service-endpoints), [custom domain](/azure/app-service/app-service-web-tutorial-custom-domain), or [Azure Front Door](/azure/frontdoor/front-door-overview). In this case, downtime depends on how long it takes to update those respective services with the new app information.
456-
- You might also be routing traffic to multiple apps at the same time using a service such as [Azure Traffic Manager](/azure/app-service/web-sites-traffic-manager). In this scenario, you can only fully switch to the new zone-redundant app after everything is deployed and tested fully.
457-
- For message-based functions, you should [write defensive functions](/azure/azure-functions/performance-reliability#write-defensive-functions) to ensure messages aren't lost during the migration.
552+
```json
553+
{
554+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
555+
"contentVersion": "1.0.0.0",
556+
"resources": [
557+
{
558+
"type": "Microsoft.Web/serverfarms",
559+
"apiVersion": "2024-04-01",
560+
"name": "<YOUR_PLAN_NAME>",
561+
"location": "<YOUR_REGION_NAME>",
562+
"sku": {
563+
"name": "EP1",
564+
"tier": "ElasticPremium",
565+
"size": "EP1",
566+
"family": "EP",
567+
"capacity": 2
568+
},
569+
...
570+
"properties": {
571+
...
572+
"zoneRedundant": true
573+
}
574+
},
575+
{
576+
"type": "Microsoft.Web/sites",
577+
"apiVersion": "2024-04-01",
578+
"name": "<YOUR_APP_NAME>",
579+
"location": "<YOUR_REGION_NAME>",
580+
"kind": "functionapp",
581+
"properties": {
582+
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', '<YOUR_PLAN_NAME>')]",
583+
"siteConfig": {
584+
"minimumElasticInstanceCount": 2
585+
}
586+
},
587+
"dependsOn": [
588+
"[resourceId('Microsoft.Web/serverfarms', '<YOUR_PLAN_NAME>')]"
589+
]
590+
}
591+
]
592+
}
593+
```
594+
595+
> [!NOTE]
596+
> Remember to update the `minimumElasticInstanceCount` property to at least 2 on all function apps in the plan to ensure zone redundancy requirements are met.
597+
598+
---
599+
600+
### Verify instance zone placement
601+
602+
After enabling zone redundancy, you can verify that your function app instances are distributed across availability zones.
603+
604+
#### [Azure portal](#tab/azure-portal)
605+
606+
1. In the Azure portal, search for and select your function app.
607+
608+
1. Under **Settings**, select **Instances**.
609+
610+
1. The **Instances** page shows each running instance and the availability zone it's placed in.
458611

459-
### Migration steps
612+
#### [Azure CLI](#tab/azure-cli)
613+
614+
Use the following Azure CLI commands to verify zone distribution:
615+
616+
```azurecli-interactive
617+
RESOURCE_ID=$(az functionapp show \
618+
--resource-group <RESOURCE_GROUP> \
619+
--name <APP_NAME> \
620+
--query id -o tsv)
621+
622+
az rest \
623+
--method get \
624+
--url "${RESOURCE_ID}/instances?api-version=2024-04-01" \
625+
--query "value[].{machineName:properties.machineName, physicalZone:properties.physicalZone}" \
626+
-o table
627+
```
628+
629+
In this example, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the names of your resource group and function app, respectively.
460630

461-
To enable an existing Premium plan function app to use availability zones, redeploy your project files to a new function app hosted in a zone-redundant Premium plan. Follow these steps:
631+
Example output:
462632

463-
1. If you're already hosted in a Premium plan in a supported region, you can reuse your existing resource group and skip to the next step. Otherwise, create a new resource group in a supported region. For a list of regions that support zone redundancy for Azure Functions Premium plans, see [Reliability in Azure Functions - Resilience to availability zone failures - Requirements](/azure/reliability/reliability-functions#requirements).
464-
1. Create a zone-redundant Premium plan in a supported region.
465-
1. Create a function app in the new Premium plan and deploy your project code to this new app using your desired [deployment method](functions-deployment-technologies.md).
466-
1. After the new app is up and running successfully, you can optionally disable or delete the nonzonal app.
633+
```output
634+
MachineName PhysicalZone
635+
-------------- --------------
636+
pl1sdlwk0002Q7 westus3-az3
637+
pl0sdlwk0002HP westus3-az1
638+
```
639+
640+
In the output:
641+
- `machineName` is the internal name of the worker instance
642+
- `physicalZone` shows the actual availability zone the instance is placed in (format: `{region}-az{N}`)
643+
- For a zone-redundant plan with 2+ instances, you should see instances distributed across different zones
644+
645+
### Troubleshooting
646+
647+
If zone redundancy is not working as expected after following these steps, review the [Common Issues and Solutions](https://techcommunity.microsoft.com/blog/appsonazureblog/deep-dive-on-availability-zones-in-azure-app-service/4433526) section in the deep dive blog post on Availability Zones in Azure App Service. While the blog post focuses on App Service plans, many troubleshooting steps apply to Elastic Premium plans as well.
648+
649+
---
467650

468651
::: zone-end
469652

0 commit comments

Comments
 (0)