-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
BlobBackupForStorageAccoutsWithoutTag_DINE.json
214 lines (214 loc) · 9.29 KB
/
BlobBackupForStorageAccoutsWithoutTag_DINE.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
{
"properties": {
"displayName": "[Preview]: Configure blob backup for all storage accounts that do not contain a given tag to a backup vault in the same region",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Enforce backup for blobs on all storage accounts that do not contain a given tag to a central backup vault. Doing this can help you manage backup of blobs contained across multiple storage accounts at scale. For more details, refer to https://aka.ms/AB-BlobBackupAzPolicies",
"metadata": {
"version": "2.0.0-preview",
"preview": true,
"category": "Backup"
},
"version": "2.0.0-preview",
"parameters": {
"vaultLocation": {
"type": "String",
"metadata": {
"displayName": "Location (Specify the location of the storage accounts that you want to protect)",
"description": "Specify the location of the storage accounts that you want to protect. Blobs in the storage accounts should be backed up to a vault in the same location. For example - CanadaCentral",
"strongType": "location"
}
},
"backupPolicyId": {
"type": "String",
"metadata": {
"displayName": "Backup Policy (of type Azure Blobs (Azure Storage) from a vault in the location chosen above)",
"description": "Specify the ID of the backup policy to be used for configuring backup for blobs. The selected Azure Backup policy should be of type Azure Blobs (Azure Storage). This policy needs to be in a vault that is present in the location chosen above. For example - /subscriptions/<SubscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.DataProtection/vaults/<VaultName>/backupPolicies/<BackupPolicyName>. Also, make sure that this Backup vault's managed identity has the Storage Account Backup Contributor role assigned on the storage accounts for which backup is to be configured."
}
},
"exclusionTagName": {
"type": "String",
"metadata": {
"displayName": "Exclusion Tag Name",
"description": "Name of the tag to use for excluding storage accounts in the scope of this policy. This should be used along with the Exclusion Tag Value parameter. Learn more at https://aka.ms/AB-BlobBackupAzPolicies"
}
},
"exclusionTagValues": {
"type": "Array",
"metadata": {
"displayName": "Exclusion Tag Values",
"description": "Value of the tag to use for excluding storage accounts in the scope of this policy (in case of multiple values, use a comma-separated list). This should be used along with the Exclusion Tag Name parameter. Learn more at https://aka.ms/AB-BlobBackupAzPolicies."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/StorageAccounts"
},
{
"field": "kind",
"equals": "StorageV2"
},
{
"field": "Microsoft.Storage/storageAccounts/sku.name",
"contains": "Standard"
},
{
"field": "Microsoft.Storage/storageAccounts/isHnsEnabled",
"notEquals": "true"
},
{
"field": "Microsoft.Storage/storageAccounts/isNfsV3Enabled",
"notEquals": "true"
},
{
"field": "location",
"equals": "[parameters('vaultLocation')]"
},
{
"anyOf": [
{
"not": {
"field": "[concat('tags[', parameters('exclusionTagName'), ']')]",
"in": "[parameters('exclusionTagValues')]"
}
},
{
"value": "[empty(parameters('exclusionTagValues'))]",
"equals": "true"
},
{
"value": "[empty(parameters('exclusionTagName'))]",
"equals": "true"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Storage/storageAccounts/blobServices",
"name": "default",
"existenceCondition": {
"field": "Microsoft.Storage/storageAccounts/blobServices/default.restorePolicy.enabled",
"equals": true
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/5e467623-bb1f-42f4-a55d-6e525e11384b"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"backupPolicyId": {
"type": "string",
"metadata": {
"description": "Backup Policy Id"
}
},
"storageAccountResourceId": {
"type": "string",
"metadata": {
"description": "ResourceId of the Storage Account"
}
},
"location": {
"type": "string",
"metadata": {
"description": "Location for all resources"
}
}
},
"variables": {
"storageAccountName": "[first(skip(split(parameters('storageAccountResourceId'), '/'), 8))]",
"dataSourceType": "Microsoft.Storage/storageAccounts/blobServices",
"resourceType": "Microsoft.Storage/storageAccounts",
"backupPolicyName": "[first(skip(split(parameters('backupPolicyId'), '/'), 10))]",
"vaultName": "[first(skip(split(parameters('backupPolicyId'), '/'), 8))]",
"vaultResourceGroup": "[first(skip(split(parameters('backupPolicyId'), '/'), 4))]",
"vaultSubscriptionId": "[first(skip(split(parameters('backupPolicyId'), '/'), 2))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"resourceGroup": "[variables('vaultResourceGroup')]",
"subscriptionId": "[variables('vaultSubscriptionId')]",
"name": "[concat('DeployProtection-',uniqueString(variables('storageAccountName')))]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"type": "Microsoft.DataProtection/backupvaults/backupInstances",
"apiVersion": "2021-01-01",
"name": "[concat(variables('vaultName'), '/', variables('storageAccountName'))]",
"properties": {
"objectType": "BackupInstance",
"dataSourceInfo": {
"objectType": "Datasource",
"resourceID": "[parameters('storageAccountResourceId')]",
"resourceName": "[variables('storageAccountName')]",
"resourceType": "[variables('resourceType')]",
"resourceUri": "[parameters('storageAccountResourceId')]",
"resourceLocation": "[parameters('location')]",
"datasourceType": "[variables('dataSourceType')]"
},
"policyInfo": {
"policyId": "[parameters('backupPolicyId')]",
"name": "[variables('backupPolicyName')]"
}
}
}
]
}
}
}
]
},
"parameters": {
"storageAccountResourceId": {
"value": "[field('id')]"
},
"backupPolicyId": {
"value": "[parameters('backupPolicyId')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
},
"versions": [
"2.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/958dbd4e-0e20-4385-a082-d3f20c2a6ad8",
"name": "958dbd4e-0e20-4385-a082-d3f20c2a6ad8"
}