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

查看:29
本文介绍了将 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, string, array, or object],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天全站免登陆