Using bool parameter type for conditions in Azure

2019-06-20 17:25发布

问题:

In an ARM Template with a following parameter:

{
  "$schema": "...",
  "contentVersion": "1.0.0.0",
  "parameters": {

  ...

    "SkipThisComponent": {
      "type": "bool"

   ...
}

how would one use it inside a resource condition?

"resources": [
    {
      "apiVersion": "...",
      "name": "...",
      "type": "...",
      "condition": "[???]",

I tried out several approaches, but it seems that equals supports only [int, string, array, or object], if needs both the condition and values to match it to etc. I didn't find a nice clean approach, all seem to be workarounds with casting...

回答1:

You can just use the variable within the condition:

"condition" : "[variables('SkipThisComponent')]"