将bool参数类型用于Azure资源管理器(ARM)模板中的条件 [英] Using bool parameter type for conditions in Azure Resource Manager (ARM) templates

查看:96
本文介绍了将bool参数类型用于Azure资源管理器(ARM)模板中的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有以下参数的ARM模板中:

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": "[???]",

我尝试了几种方法,但是equals似乎仅支持[int,字符串,数组或对象],if既需要条件也需要将其匹配的值,等等.我没有找到干净的方法,似乎都是铸造的解决方法...

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...

推荐答案

您可以在条件内使用变量:

You can just use the variable within the condition:

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

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

逻辑功能参考

这篇关于将bool参数类型用于Azure资源管理器(ARM)模板中的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆