Depoyifnotexist for VM boot diagnostics

There is a client need to create a dine process for VM boot diagnostics, I written the code but it is not working as expected.

Expectation:

When ever it finds the vm without boot dignostics enabled it should enable it automatically.

My code:

{
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Compute/virtualMachine"
},
"then": {
"effect": "DeployIfNotExists",
"details": {
"type": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics.enabled",
"equals": "false"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/diagnosticsProfile.bootDiagnostics",
"apiVersion": "2020-06-01",
"dependsOn": [],
"properties": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
}
}
}
],
"outputs": {}
}
}
}
}
}
}
}

Please check and let me where I did the mistake in code

submitted by /u/naveenbegurnagaraj
[link] [comments]

Read more here: https://www.reddit.com/r/AZURE/comments/nx8qhb/depoyifnotexist_for_vm_boot_diagnostics/

Content Attribution

This content was originally published by /u/naveenbegurnagaraj at Microsoft Azure, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: