Reputation: 5822
I am trying to figure out in ARM Templates, how I can essentially use conditions where it will run/execute based on a condition.
This would be for:
I tried adding the following to the CustomScriptExtensions but received an error that "condition" was not permitted or something to that effect
{
"condition": "[equals(parameters('performHealthCheck'), 'true')",
"name": "CustomScriptExtension",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.9",
"settings": {
"fileUris": [
"[parameters('scriptUri')]"
],
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -NonInteractive -NoProfile -ExecutionPolicy Bypass -File ', parameters('scriptUri'))]"
}
}
How can one do something like this? I don't want to be using different ARM Templates based on different conditions if there is just 1 or 2 things to execute based on a condition.
For the case of the diffDiskSettings, I want to use it or not use it (seems this option only works for ephemeral disks and you can specify it otherwise "None" is not valid if you dont want to use diffDiskSettings!) Basically I want to emit it if the condition has been met.
Thank you
Upvotes: 0
Views: 289
Reputation: 5492
It would have helped to have the exact error message and the complete ARM template to troubleshoot the issue further. Nonetheless, you might probably be running into this error for not having applied the condition
to the whole resource.
As @Matthew had also mentioned above, know that conditional deployment doesn't cascade to child resources. If you want to conditionally deploy a resource and its child resources, you must apply the same condition to each resource type.
Check this quickstart template for reference: 101-sql-logical-server
Upvotes: 1