Skip to content

Commit ad9c5cf

Browse files
authored
Merge pull request #301537 from mumian/0618-zones-function
Document Bicep zone functions
2 parents d920155 + 53e9a6d commit ad9c5cf

File tree

3 files changed

+96
-16
lines changed

3 files changed

+96
-16
lines changed

articles/azure-resource-manager/bicep/bicep-functions-resource.md

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.topic: reference
55
ms.custom:
66
- devx-track-bicep
77
- build-2025
8-
ms.date: 05/14/2025
8+
ms.date: 06/18/2025
99
---
1010

1111
# Resource functions for Bicep
@@ -501,7 +501,7 @@ Namespace: [az](bicep-functions.md#namespaces-for-functions).
501501
| providerNamespace | Yes | string | The resource provider namespace for the resource type to check for zone support. |
502502
| resourceType | Yes | string | The resource type to check for zone support. |
503503
| location | Yes | string | The region to check for zone support. |
504-
| numberOfZones | No | integer | The number of logical zones to return. The default is 1. The number must be a positive integer from 1 to 3. Use 1 for single-zoned resources. For multi-zoned resources, the value must be less than or equal to the number of supported zones. |
504+
| numberOfZones | No | integer | The number of logical zones to return. The default is 1. The number must be a positive integer from 1 to 3. Use 1 for single-zoned resources. For multi-zoned resources, the value must be less than or equal to the number of supported zones. |
505505
| offset | No | integer | The offset from the starting logical zone. The function returns an error if offset plus numberOfZones exceeds the number of supported zones. |
506506

507507
### Return value
@@ -533,9 +533,9 @@ When the resource type or region doesn't support zones, an empty array is return
533533

534534
### Remarks
535535

536-
There are different categories for Azure Availability Zones - zonal and zone-redundant. The `pickZones` function can be used to return an availability zone for a zonal resource. For zone redundant services (ZRS), the function returns an empty array. Zonal resources typically have a `zones` property at the top level of the resource definition. To determine the category of support for availability zones, see [Azure services that support availability zones](../../reliability/availability-zones-service-support.md).
536+
There are different categories for Azure Availability Zones - zonal and zone-redundant. The `pickZones` function can be used to return an availability zone for a zonal resource. For zone redundant services (ZRS), the function returns an empty array. Zonal resources typically have a `zones` property at the top level of the resource definition. To determine the category of support for availability zones, see [Azure services that support availability zones](../../reliability/availability-zones-service-support.md).
537537

538-
To determine if a given Azure region or location supports availability zones, call the `pickZones` function with a zonal resource type, such as `Microsoft.Network/publicIPAddresses`. If the response isn't empty, the region supports availability zones.
538+
To determine if a given Azure region or location supports availability zones, call the `pickZones` function with a zonal resource type, such as `Microsoft.Network/publicIPAddresses`. If the response isn't empty, the region supports availability zones.
539539

540540
### pickZones example
541541

@@ -756,7 +756,7 @@ resource policyAssignment 'Microsoft.Authorization/policyAssignments@2024-04-01'
756756

757757
`toLogicalZone(subscriptionId, location, physicalZone)`
758758

759-
Returns the logical availability zone (e.g., `1`, `2`, or `3`) corresponding to a physical availability zone for a specified subscription in a given Azure region.
759+
Returns the logical availability zone (for example, `1`, `2`, or `3`) corresponding to a physical availability zone for a specified subscription in a given Azure region.
760760

761761
Namespace: [az](bicep-functions.md#namespaces-for-functions)
762762

@@ -770,15 +770,15 @@ Namespace: [az](bicep-functions.md#namespaces-for-functions)
770770

771771
### Return value
772772

773-
A string representing the logical availability zone (e.g., `1`, `2`, or `3`) that corresponds to the specified physical zone in the given region and subscription. If the physical zone is invalid or not supported, an empty string (`''`) is returned.
773+
A string representing the logical availability zone (for example, `1`, `2`, or `3`) that corresponds to the specified physical zone in the given region and subscription. If the physical zone is invalid or not supported, an empty string (`''`) is returned.
774774

775775
### Remarks
776776

777777
* The `toLogicalZone` function retrieves the logical zone mapping based on the subscription’s zone configuration in the specified region.
778-
* Logical zones are standardized identifiers (e.g., `1`, `2`, `3`) used in resource configurations to ensure consistent zone assignments across Azure services.
778+
* Logical zones are standardized identifiers (for example, `1`, `2`, `3`) used in resource configurations to ensure consistent zone assignments across Azure services.
779779
* Physical zone identifiers are region-specific and may vary between subscriptions. Use the [`toPhysicalZone`](#tophysicalzone) function to reverse this mapping.
780780
* The function requires that the region supports availability zones. For a list of supported regions, see [Azure services that support availability zones](../../reliability/availability-zones-service-support.md).
781-
* If the physical zone does not exist or is not mapped for the subscription, the function returns an empty string.
781+
* If the physical zone doesn't exist or isn't mapped for the subscription, the function returns an empty string.
782782
* This function is useful for aligning physical zone deployments with logical zone configurations in templates, especially for cross-subscription or multi-region scenarios.
783783

784784
### Examples
@@ -825,13 +825,52 @@ Expected output:
825825
| ---- | ---- | ----- |
826826
| logicalZone | String | `1` |
827827

828-
---
828+
## toLogicalZones
829+
830+
`toLogicalZones(subscriptionId, location, physicalZones)`
831+
832+
Returns the logical availability zones (for example, `1`, `2`, or `3`) corresponding to physical availability zones for a specified subscription in a given Azure region. To convert a single physical zone, use the [`toLogicalZone`](#tologicalzone) function.
833+
834+
Namespace: [az](bicep-functions.md#namespaces-for-functions)
835+
836+
### Parameters
837+
838+
| Parameter | Required | Type | Description |
839+
|:--- |:--- |:--- |:--- |
840+
| subscriptionId | Yes | string | The ID of the Azure subscription (for example, `12345678-1234-1234-1234-1234567890ab`). |
841+
| location | Yes | string | The Azure region that supports availability zones (for example, `westus2`). |
842+
| physicalZones | Yes | array | An array of physical zone names to convert to logical zones (for example, a data center-specific identifier like `westus2-az1`, `westus2-az2`, ...). |
843+
844+
### Return value
845+
846+
An array of logical zone names corresponding to the provided physical zones (for example, `1`, `2`, or `3`). If a physical zone is invalid or not supported, an empty string (`''`) is returned.
847+
848+
### Remarks
849+
850+
The `toLogicalZones` function maps physical zone names to their logical zone equivalents for a specified Azure subscription and region. This is useful for configuring or querying resources based on logical zones within an Azure region. The function requires a valid subscription ID, a supported Azure location, and an array of physical zone names. If a physical zone is invalid or not available in the specified location, the function may return an empty string for that zone or throw an error, depending on the context.
851+
852+
### Examples
853+
854+
The following example retrieves the logical zones for a list of physical zones in West US 2 for a specific subscription:
855+
856+
```bicep
857+
param subscriptionId string = '12345678-1234-1234-1234-1234567890ab'
858+
param physicalZones array = ['westus2-az1', 'westus2-az2', 'westus2-az3']
859+
860+
output logicalZones array = toLogicalZones(subscriptionId, 'westus2', physicalZones)
861+
```
862+
863+
Expected output:
864+
865+
| Name | Type | Value |
866+
| ---- | ---- | ----- |
867+
| logicalZone | array | ["1","2","3"] |
829868

830869
## toPhysicalZone
831870

832871
`toPhysicalZone(subscriptionId, location, logicalZone)`
833872

834-
Returns the physical availability zone identifier (e.g., a data center-specific identifier like `westus2-az1`) corresponding to a logical availability zone for a specified subscription in a given Azure region.
873+
Returns the physical availability zone identifier (for example, a data center-specific identifier like `westus2-az1`) corresponding to a logical availability zone for a specified subscription in a given Azure region.
835874

836875
Namespace: [az](bicep-functions.md#namespaces-for-functions)
837876

@@ -841,19 +880,19 @@ Namespace: [az](bicep-functions.md#namespaces-for-functions)
841880
|:--- |:--- |:--- |:--- |
842881
| subscriptionId | Yes | string | The ID of the Azure subscription (for example, `12345678-1234-1234-1234-1234567890ab`). |
843882
| location | Yes | string | The Azure region that supports availability zones (for example, `westus2`). |
844-
| logicalZone | Yes | string | The logical availability zone (e.g., `1`, `2`, or `3`). |
883+
| logicalZone | Yes | string | The logical availability zone (for example, `1`, `2`, or `3`). |
845884

846885
### Return value
847886

848-
A string representing the physical availability zone identifier (e.g., `westus2-az1`) that corresponds to the specified logical zone in the given region and subscription. If the logical zone is invalid or not supported, an empty string (`''`) is returned.
887+
A string representing the physical availability zone identifier (for example, `westus2-az1`) that corresponds to the specified logical zone in the given region and subscription. If the logical zone is invalid or not supported, an empty string (`''`) is returned.
849888

850889
### Remarks
851890

852891
* The `toPhysicalZone` function retrieves the physical zone mapping based on the subscription’s zone configuration in the specified region.
853-
* Physical zones are data center-specific identifiers that may vary between subscriptions, while logical zones (e.g., `1`, `2`, `3`) are standardized for resource configurations.
892+
* Physical zones are data center-specific identifiers that may vary between subscriptions, while logical zones (for example, `1`, `2`, `3`) are standardized for resource configurations.
854893
* Use the `toLogicalZone` function to reverse this mapping, converting a physical zone to its logical equivalent.
855894
* The function requires that the region supports availability zones. For a list of supported regions, see [Azure services that support availability zones](../../reliability/availability-zones-service-support.md).
856-
* If the logical zone does not exist or is not mapped for the subscription, the function returns an empty string.
895+
* If the logical zone doesn't exist or isn't mapped for the subscription, the function returns an empty string.
857896
* This function is useful for scenarios requiring physical zone identifiers, such as logging, auditing, or cross-subscription zone alignment in multi-region deployments.
858897

859898
### Examples
@@ -900,7 +939,46 @@ Expected output:
900939
| ---- | ---- | ----- |
901940
| physicalZone | String | `westus2-az1` |
902941

903-
---
942+
## toPhysicalZones
943+
944+
`toPhysicalZones(subscriptionId, location, logicalZones)`
945+
946+
Returns the physical availability zone identifiers (for example, a data center-specific identifier like `westus2-az1`) corresponding to logical availability zones for a specified subscription in a given Azure region. To convert a single logical zone, use the [`toPhysicalZone`](#tophysicalzone) function.
947+
948+
Namespace: [az](bicep-functions.md#namespaces-for-functions)
949+
950+
### Parameters
951+
952+
| Parameter | Required | Type | Description |
953+
|:--- |:--- |:--- |:--- |
954+
| subscriptionId | Yes | string | The ID of the Azure subscription (for example, `12345678-1234-1234-1234-1234567890ab`). |
955+
| location | Yes | string | The Azure region that supports availability zones (for example, `westus2`). |
956+
| logicalZone | Yes | string[] | The logical availability zones (for example, `1`, `2`, or `3`) to convert to physical zones. |
957+
958+
### Return value
959+
960+
An array of physical zone names (for example, `westus2-az1`, `westus2-az2` ) corresponding to the provided logical zones. If a logical zone is invalid or not supported, an empty string (`''`) is returned.
961+
962+
### Remarks
963+
964+
The `toPhysicalZones` function maps logical zone names to their physical zone equivalents for a specified Azure subscription and region. This is useful for deploying or configuring resources in specific physical zones within an Azure region. The function requires a valid subscription ID, a supported Azure location, and an array of logical zone names. If a logical zone is invalid or not available in the specified location, the function may return an empty string for that zone or throw an error, depending on the context.
965+
966+
### Examples
967+
968+
The following example retrieves the physical zones for a list of logical zones in West US 2 for a specific subscription:
969+
970+
```bicep
971+
param subscriptionId string = '12345678-1234-1234-1234-1234567890ab'
972+
param logicalZones array = ['1', '2', '3']
973+
974+
output physicalZones array = toPhysicalZones(subscriptionId, 'westus2', logicalZones)
975+
```
976+
977+
Expected output (assuming logical zone `1` maps to `westus2-az1`, logical zone `1` maps to `westus2-az1`, and logical zone `3` maps to `westus2-az3`):
978+
979+
| Name | Type | Value |
980+
| ---- | ---- | ----- |
981+
| physicalZone | array | ["westus2-az1","westus2-az2","westus2-az3"] |
904982

905983
## Next steps
906984

articles/azure-resource-manager/bicep/bicep-functions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ The following functions are available for getting resource values. Most of these
160160
* [subscriptionResourceId](./bicep-functions-resource.md#subscriptionresourceid)
161161
* [tenantResourceId](./bicep-functions-resource.md#tenantresourceid)
162162
* [toLogicalZone](./bicep-functions-resource.md#tologicalzone)
163+
* [toLogicalZones](./bicep-functions-resource.md#tologicalzones)
163164
* [toPhysicalZone](./bicep-functions-resource.md#tophysicalzone)
165+
* [toPhysicalZones](./bicep-functions-resource.md#tophysicalzones)
164166

165167
## Scope functions
166168

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ items:
355355
displayName: getSecret,readEnvironmentVariable
356356
href: bicep-functions-parameters-file.md
357357
- name: Resource functions
358-
displayName: extensionResourceId,getSecret,listAccountSas,ListKeys,listSecrets,list,managementGroupResourceId,pickZones,providers,reference,resourceId,subscriptionResourceId,tenantResourceId,toLogicalZone,toPhysicalZone
358+
displayName: extensionResourceId,getSecret,listAccountSas,ListKeys,listSecrets,list,managementGroupResourceId,pickZones,providers,reference,resourceId,subscriptionResourceId,tenantResourceId,toLogicalZone,toLogicalZones,toPhysicalZone,toPhysicalZones
359359
href: bicep-functions-resource.md
360360
- name: Scope functions
361361
displayName: managementGroup,resourceGroup,subscription,tenant

0 commit comments

Comments
 (0)