Gallery › Storage › Azure Community Policy
Deploy Storage Advanced Threat Protection - Tag Exemption
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode Indexed Version 1.0.0
This Policy will deploy Storage ATP to all Storage Accounts unless they have a tag and value that you define in this Policy. This allows you to exempt certain Storage Accounts from this Policy by leveraging Tags.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 95 lines
{
"name": "5d965918-9928-4440-8760-9d6618ead5bf",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deploy Storage Advanced Threat Protection - Tag Exemption",
"description": "This Policy will deploy Storage ATP to all Storage Accounts unless they have a tag and value that you define in this Policy. This allows you to exempt certain Storage Accounts from this Policy by leveraging Tags.",
"metadata": {
"version": "1.0.0",
"category": "Storage"
},
"mode": "Indexed",
"parameters": {
"tagName": {
"type": "String"
},
"tagValue": {
"type": "String"
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"notEquals": "[parameters('tagValue')]"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Security/advancedThreatProtectionSettings",
"name": "current",
"existenceCondition": {
"anyOf": [
{
"field": "Microsoft.Security/advancedThreatProtectionSettings/isEnabled",
"equals": "true"
}
]
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2019-01-01",
"type": "Microsoft.Storage/storageAccounts/providers/advancedThreatProtectionSettings",
"name": "[concat(parameters('storageAccountName'), '/Microsoft.Security/current')]",
"properties": {
"isEnabled": true
}
}
]
},
"parameters": {
"storageAccountName": {
"value": "[field('name')]"
}
}
}
}
}
}
}
}
}Bylaw5d965918-9928-4440-8760-9d6618ead5bf.bylaw.ps1 · 42 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '5d965918-9928-4440-8760-9d6618ead5bf' {
Properties @{
DisplayName = 'Deploy Storage Advanced Threat Protection - Tag Exemption'
Description = 'This Policy will deploy Storage ATP to all Storage Accounts unless they have a tag and value that you define in this Policy. This allows you to exempt certain Storage Accounts from this Policy by leveraging Tags.'
Version = '1.0.0'
Category = 'Storage'
Mode = 'Indexed'
}
Parameter TagName @{
Type = 'String'
}
Parameter TagValue @{
Type = 'String'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'AuditIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Storage/storageAccounts' {
Require 'tag (Param TagName) is the TagValue parameter' {
Tag (Param TagName) | Must -Be (Param TagValue)
}
}
DeployIfNotExists 'Microsoft.Security/advancedThreatProtectionSettings' -Role 'Security Admin' -Name 'current' -Effect (Param Effect) {
Require 'isEnabled is as required' {
AnyOf {
Field isEnabled | Must -Be 'true'
}
}
Deployment -TemplateFile './templates/5d965918-9928-4440-8760-9d6618ead5bf.json' -Parameters ([ordered]@{
storageAccountName = (Arm '[field(''name'')]')
})
}
}Its deployment templates are written beside it:
templates/5d965918-9928-4440-8760-9d6618ead5bf.json
Source: policyDefinitions/Storage/deploy-storage-advanced-threat-protection-tag-exemption/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw