Skip to content

Instantly share code, notes, and snippets.

@PsychoData
Last active July 8, 2021 07:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save PsychoData/27c5028a5a78237f9910d4f652f6b269 to your computer and use it in GitHub Desktop.
Boot Diagnostics - DeployIfNotExist
{
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"field": "tags",
"notContains": "IgnoreBootDiagnostics"
},
{
"field": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics.storageUri",
"notContains": "[parameters('StorageURI')]"
},
{
"not": {
"field": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics.storageUri",
"equals": ""
}
}
]
},
"then": {
"effect": "modify",
"details": {
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/9980e02c-c2be-4d73-94e8-173b1dc7cf3c"
],
"conflictEffect": "audit",
"operations": [
{
"operation": "addOrReplace",
"field": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics.storageUri",
"value": "[parameters('StorageURI')]"
},
{
"operation": "addOrReplace",
"field": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics.enabled",
"value": true
}
]
}
}
},
"parameters": {
"StorageURI": {
"type": "String",
"metadata": {
"displayName": "StorageURI",
"description": "Storage Account that will be applied to any account that does not already have one applied."
},
"defaultValue": "https://YourBlobStorage.blob.core.windows.net"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment