@@ -13,77 +13,10 @@ ms.author: timwarner
13
13
This article provides information on how to export your existing Azure Policy resources. Exporting
14
14
your resources is useful and recommended for backup, but is also an important step in your journey
15
15
with Cloud Governance and treating your [ policy-as-code] ( ../concepts/policy-as-code.md ) . Azure
16
- Policy resources can be exported through [ Azure portal ] ( #export-with-azure-portal ) ,
16
+ Policy resources can be exported through
17
17
[ Azure CLI] ( #export-with-azure-cli ) , [ Azure PowerShell] ( #export-with-azure-powershell ) , and each of
18
18
the supported SDKs.
19
19
20
- ## Export with Azure portal
21
-
22
- > [ !NOTE]
23
- > Exporting Azure Policy resources from the Azure portal isn't available for Azure sovereign clouds.
24
-
25
- To export a policy definition from Azure portal, follow these steps:
26
-
27
- 1 . Launch the Azure Policy service in the Azure portal by clicking ** All services** , then searching
28
- for and selecting ** Policy** .
29
-
30
- 1 . Select ** Definitions** on the left side of the Azure Policy page.
31
-
32
- 1 . Use the ** Export definitions** button or select the ellipsis on the row of a policy definition
33
- and then select ** Export definition** .
34
-
35
- 1 . Select the ** Sign in with GitHub** button. If you haven't yet authenticated with GitHub to
36
- authorize Azure Policy to export the resource, review the access the
37
- [ GitHub Action] ( https://github.com/features/actions ) needs in the new window that opens and
38
- select ** Authorize AzureGitHubActions** to continue with the export process. Once complete, the
39
- new window self-closes.
40
-
41
- 1 . On the ** Basics** tab, set the following options, then select the ** Policies** tab or ** Next :
42
- Policies** button at the bottom of the page.
43
-
44
- - ** Repository filter** : Set to _ My repositories_ to see only repositories you own or _ All
45
- repositories_ to see all you granted the GitHub Actions access to.
46
- - ** Repository** : Set to the repository that you want to export the Azure Policy resources to.
47
- - ** Branch** : Set the branch in the repository. Using a branch other than the default is a good
48
- way to validate your updates before merging further into your source code.
49
- - ** Directory** : The _ root level folder_ to export the Azure Policy resources to. Subfolders
50
- under this directory are created based on what resources are exported.
51
-
52
- 1 . On the ** Policies** tab, set the scope to search by selecting the ellipsis and picking a
53
- combination of management groups, subscriptions, or resource groups.
54
-
55
- 1 . Use the ** Add policy definition(s)** button to search the scope for which objects to export. In
56
- the side window that opens, select each object to export. Filter the selection by the search box
57
- or the type. Once you've selected all objects to export, use the ** Add** button at the bottom of
58
- the page.
59
-
60
- 1 . For each selected object, select the desired export options such as _ Only Definition_ or
61
- _ Definition and Assignment(s)_ for a policy definition. Then select the ** Review + Export** tab
62
- or ** Next : Review + Export** button at the bottom of the page.
63
-
64
- > [ !NOTE]
65
- > If option _ Definition and Assignment(s)_ is chosen, only policy assignments within the scope
66
- > set by the filter when the policy definition is added are exported.
67
-
68
- 1 . On the ** Review + Export** tab, check the details match and then use the ** Export** button at the
69
- bottom of the page.
70
-
71
- 1 . Check your GitHub repo, branch, and _ root level folder_ to see that the selected resources are
72
- now exported to your source control.
73
-
74
- The Azure Policy resources are exported into the following structure within the selected GitHub
75
- repository and _ root level folder_ :
76
-
77
- ``` text
78
- |
79
- |- <root level folder>/ ________________ # Root level folder set by Directory property
80
- | |- policies/ ________________________ # Subfolder for policy objects
81
- | |- <displayName>_<name>____________ # Subfolder based on policy displayName and name properties
82
- | |- policy.json _________________ # Policy definition
83
- | |- assign.<displayName>_<name>__ # Each assignment (if selected) based on displayName and name properties
84
- |
85
- ```
86
-
87
20
## Export with Azure CLI
88
21
89
22
Azure Policy definitions, initiatives, and assignments can each be exported as JSON with
0 commit comments