|
1 | 1 | --- |
2 | 2 | title: Deploy a Custom Azure Policy in an Azure Extended Zone |
3 | | -description: Learn how to deploy a custom Azure Policy in an Azure Extended Zone. |
| 3 | +description: Learn how to deploy a custom Azure policy in an Azure extended zone. |
4 | 4 | author: svaldesgzz |
5 | 5 | ms.author: svaldes |
6 | 6 | ms.service: azure-extended-zones |
7 | 7 | ms.topic: how-to |
8 | 8 | ms.date: 02/12/2026 |
9 | 9 | --- |
10 | 10 |
|
11 | | -# Create a custom Azure Policy in an Azure Extended Zone |
| 11 | +# Create a custom Azure policy in an Azure extended zone |
| 12 | + |
| 13 | +In this article, you learn how to create and deploy a custom Azure policy in an Azure extended zone. |
12 | 14 |
|
13 | | -In this article, you learn how to create and deploy a custom Azure Policy in an Extended Zone. |
14 | 15 | > [!NOTE] |
15 | | -> Azure Policy is supported in Azure Extended Zones with custom policies. Built-in Azure Policy definitions aren't supported in Extended Zones yet. Thus, to enforce governance in Extended Zones you must create and deploy custom Azure Policy definitions that are tailored to the unique characteristics of these zones, namely ***extendedLocation***, ***extendedLocation.name***, and ***extendedLocation.type***. You may find it helpful to use built-in policy definitions as a reference when creating your custom policies. |
| 16 | +> Azure Policy is supported in Azure Extended Zones with custom policies. Built-in Azure Policy definitions aren't supported in extended zones yet. To enforce governance in extended zones, you must create and deploy custom Azure Policy definitions that are tailored to the unique characteristics of these zones. Examples are **extendedLocation**, **extendedLocation.name**, and **extendedLocation.type**. You might find it helpful to use built-in policy definitions as a reference when you create your custom policies. |
16 | 17 |
|
17 | 18 | ## Prerequisites |
18 | 19 |
|
19 | | -- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn). |
20 | | - |
21 | | -- Access to an Extended Zone. For more information, see [Request access to an Azure Extended Zone](request-access.md). |
22 | | - |
23 | | -- Basic understanding of Azure Policy. For more information, see [What is Azure Policy?](/azure/governance/policy/overview) |
| 20 | +- An Azure account with an active subscription. If you don't have an account, you can [create an account for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn). |
| 21 | +- Access to an extended zone. For more information, see [Request access to an Azure extended zone](request-access.md). |
| 22 | +- Basic understanding of Azure Policy. For more information, see [What is Azure Policy?](/azure/governance/policy/overview). |
24 | 23 |
|
25 | 24 | ## Sign in to Azure |
26 | 25 |
|
27 | 26 | Sign in to the [Azure portal](https://portal.azure.com) with your Azure account. |
28 | 27 |
|
29 | | -## Create a custom Azure Policy in an Azure Extended Zone |
| 28 | +## Create a custom Azure Policy in an Azure extended zone |
30 | 29 |
|
31 | | -In this section, you create a custom Azure Policy in an Extended Zone. |
| 30 | +In this section, you create a custom Azure policy in an extended zone. |
32 | 31 |
|
33 | | -For this example, we created an Allowed Locations policy that restricts the locations where resources can be deployed. |
| 32 | +For this example, you create an Allowed Locations policy that restricts the locations where resources can be deployed. |
34 | 33 |
|
35 | | -1. In the search box at the top of the portal, enter ***policy***. Select **Policy** from the search results. |
| 34 | +1. In the search box at the top of the portal, enter **policy**. Select **Policy** from the search results. |
36 | 35 |
|
37 | | -1. In **Policy**, navigate to **Authoring → Definitions**. |
| 36 | +1. On the **Policy** pane, go to **Authoring** > **Definitions**. |
38 | 37 |
|
39 | 38 | 1. Select **+ Policy definition**. |
40 | 39 |
|
41 | | -1. In **Create a policy definition**, fill in the required fields. Use the following table for guidance. |
42 | | - |
43 | | -**Required fields:** |
44 | | - |
45 | | -| Field | Guidance | |
46 | | -| ------ | --------- | |
47 | | -| Definition location | Use a **management group** for enterprise-wide governance (recommended), or a **subscription** for more granular control. | |
48 | | -| Name | Use a clear, intent-based name (for example, `Deny-NonApproved-Locations`). | |
49 | | -| Description | Explain what the policy enforces and why. | |
50 | | -| Category | Use an existing category or create one (for example, *Governance* or *Networking*). | |
51 | | - |
52 | | - |
53 | | -5. Next, define the Policy Rule. In the **Policy rule** section, for this example, enter the following JSON code to create a policy that denies the creation of resources in locations other than an Azure Extended Zone: |
54 | | - |
55 | | -```json |
56 | | -{ |
57 | | - "mode": "Indexed", |
58 | | - "parameters": { |
59 | | - "listOfAllowedLocations": { |
60 | | - "type": "Array", |
61 | | - "metadata": { |
62 | | - "description": "The list of locations that can be specified when deploying resources.", |
63 | | - "strongType": "location", |
64 | | - "displayName": "Allowed locations" |
65 | | - } |
66 | | - } |
67 | | - }, |
68 | | - "policyRule": { |
69 | | - "if": { |
70 | | - "allOf": [ |
71 | | - { |
72 | | - "field": "location", |
73 | | - "notIn": "[parameters('listOfAllowedLocations')]" |
74 | | - }, |
75 | | - { |
76 | | - "field": "location", |
77 | | - "notEquals": "global" |
78 | | - }, |
79 | | - { |
80 | | - "field": "extendedLocation.name", |
81 | | - "notEquals": "losangeles" |
82 | | - }, |
83 | | - { |
84 | | - "field": "type", |
85 | | - "notEquals": "Microsoft.AzureActiveDirectory/b2cDirectories" |
| 40 | +1. On the **Create a policy definition** pane, fill in the required fields. For guidance on the required fields, use the following table: |
| 41 | + |
| 42 | + | Field | Guidance | |
| 43 | + | ------ | --------- | |
| 44 | + | Definition location | Use a management group for enterprise-wide governance (recommended) or a subscription for more granular control. | |
| 45 | + | Name | Use a clear, intent-based name (for example, `Deny-NonApproved-Locations`). | |
| 46 | + | Description | Explain what the policy enforces and why. | |
| 47 | + | Category | Use an existing category or create one (for example, Governance or Networking). | |
| 48 | + |
| 49 | +1. Define the policy rule. In the **Policy rule** section, for this example, enter the following JSON code to create a policy that denies the creation of resources in locations other than an Azure extended zone. |
| 50 | + |
| 51 | + ```json |
| 52 | + { |
| 53 | + "mode": "Indexed", |
| 54 | + "parameters": { |
| 55 | + "listOfAllowedLocations": { |
| 56 | + "type": "Array", |
| 57 | + "metadata": { |
| 58 | + "description": "The list of locations that can be specified when deploying resources.", |
| 59 | + "strongType": "location", |
| 60 | + "displayName": "Allowed locations" |
86 | 61 | } |
87 | | - ] |
| 62 | + } |
88 | 63 | }, |
89 | | - "then": { |
90 | | - "effect": "deny" |
| 64 | + "policyRule": { |
| 65 | + "if": { |
| 66 | + "allOf": [ |
| 67 | + { |
| 68 | + "field": "location", |
| 69 | + "notIn": "[parameters('listOfAllowedLocations')]" |
| 70 | + }, |
| 71 | + { |
| 72 | + "field": "location", |
| 73 | + "notEquals": "global" |
| 74 | + }, |
| 75 | + { |
| 76 | + "field": "extendedLocation.name", |
| 77 | + "notEquals": "losangeles" |
| 78 | + }, |
| 79 | + { |
| 80 | + "field": "type", |
| 81 | + "notEquals": "Microsoft.AzureActiveDirectory/b2cDirectories" |
| 82 | + } |
| 83 | + ] |
| 84 | + }, |
| 85 | + "then": { |
| 86 | + "effect": "deny" |
| 87 | + } |
91 | 88 | } |
92 | 89 | } |
93 | | -} |
94 | | -``` |
95 | | -In this example, replace `losangeles` with the name of the Extended Zone location you have access to. You can find the location name in the Azure portal when deploying resources in the Extended Zone, or by using Azure CLI or PowerShell. |
96 | | -> [!NOTE] |
97 | | -> The **extendedlocation.name** or similar Extended Zone-specific fields may be highlighted as errors in the json editor. You may disregard this, as you can still successfully save, deploy and enforce the policy with these fields included. |
| 90 | + ``` |
| 91 | + |
| 92 | + In this example, replace `losangeles` with the name of the extended zone location to which you have access. You can find the location name in the Azure portal when you deploy resources in the extended zone, or by using the Azure CLI or Azure PowerShell. |
98 | 93 |
|
99 | | -6. Select **Save** to create the policy definition. |
| 94 | + > [!NOTE] |
| 95 | + > The **extendedlocation.name** property or similar extended zone-specific fields might be highlighted as errors in the JSON editor. You can disregard this notification because you can still successfully save, deploy, and enforce the policy with these fields included. |
100 | 96 |
|
| 97 | +1. Select **Save** to create the policy definition. |
101 | 98 |
|
102 | 99 | ## Policy management and monitoring |
103 | 100 |
|
104 | | -You can manage and monitor your Azure Policies in the Policy home dashboard in the Azure portal. |
| 101 | +You can manage and monitor your Azure policies on the **Policy** dashboard in the Azure portal. |
105 | 102 |
|
106 | 103 | ## Clean up resources |
107 | | -If you're done working with resources from this tutorial, use the following steps to delete any of the policy assignments or definitions created above: |
108 | 104 |
|
109 | | -1. Select **Definitions** (or **Assignments** if you're trying to delete an assignment) under **Authoring** in the left side of the Azure Policy page. |
| 105 | +If you're finished working with resources from this tutorial, you can delete any of the policy assignments or definitions that you created. |
110 | 106 |
|
111 | | -1. Search for the new initiative or policy definition (or assignment) you want to remove. |
| 107 | +1. On the service menu on the **Azure Policy** page, under **Authoring**, select **Definitions**. Or select **Assignments** if you're trying to delete an assignment. |
112 | 108 |
|
113 | | -1. Right-click the row or select the ellipses at the end of the definition (or assignment), and select **Delete definition** (or **Delete assignment**). |
| 109 | +1. Search for the new initiative or policy definition (or assignment) that you want to remove. |
| 110 | + |
| 111 | +1. Right-click the row or select the ellipses at the end of the definition (or assignment). Select **Delete definition** (or **Delete assignment**). |
114 | 112 |
|
115 | 113 | ## Related content |
| 114 | + |
116 | 115 | - [What is Azure Policy?](/azure/governance/policy/overview) |
117 | 116 | - [What is Azure Extended Zones?](overview.md) |
118 | | -- [Deploy a virtual machine in an Extended Zone](deploy-vm-portal.md) |
| 117 | +- [Deploy a virtual machine in an extended zone](deploy-vm-portal.md) |
119 | 118 | - [Frequently asked questions](faq.md) |
0 commit comments