ARM故障转移组条件关联

ARM故障转移组条件关联

本文介绍了数据库的Azure ARM故障转移组条件关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个ARM模板,在该模板中,我可以有条件地控制故障转移组中数据库之一的关联.这是我的示例资源模板

I am working on an ARM template where I can conditionally control the association of one of the databases in the fail-over group. Here is my sample resource template

 {
      "condition": "[variables('Resources').IsFailover]",
      "name": "[variables('SqlServer').FailoverGroup.Name]",
      "type": "failoverGroups",
      "apiVersion": "2015-05-01-preview",
      "location": "[variables('SqlServer').Servers.Primary.ResourceLocation]",
      "tags":
      {
        "displayName": "Failover Group"
      },
      "properties":
      {
        "partnerServers":
        [
          {
            ...
          }
        ],
        "readWriteEndpoint":
        {
            ....
        },
        "readOnlyEndpoint":
        {
          "failoverPolicy": "Disabled"
        },
        "databases":
        [
          "[variables('SqlServer').Databases.DBOne.ResourceId]",
          "[variables('SqlServer').Databases.DBTwo.ResourceId]",
          "[variables('SqlServer').Databases.DBThree.ResourceId]"
        ]
      },
      "dependsOn":
      [
        "[variables('SqlServer').Servers.Primary.ResourceId]",
        "[variables('SqlServer').Servers.Secondary.ResourceId]",
        "[variables('SqlServer').Databases.DBOne.ResourceId]",
        "[variables('SqlServer').Databases.DBTwo.ResourceId]",
        "[variables('SqlServer').Databases.DBThree.ResourceId]"
      ]
}

我想实现仅当标志(输入参数)为true时才将DBTwo(数据库)与故障转移组相关联,而如果标志为false则不希望将同一组中的所有故障关联起来.

I want to achieve something like associating the DBTwo(database) with the fail-over group only if a flag(input parameter) is true and not associating if the flag is false all from the same group.

有没有办法从ARM做到这一点?

Is there a way to do this from ARM ?

预先感谢您的任何意见和建议.

Thanks in advance for any advice and suggestions.

推荐答案

是的,手臂模板支持条件句(咳嗽,咳嗽).您可以使用if()函数和其他几个函数(andnotor等)来创建条件.

Yes, arm template has support for conditionals (cough, cough). you can use if() function and several others (and, not, or, etc) to create conditions.

https://docs.microsoft.com/zh-CN/azure/azure-resource-manager/resource-group-template-functions-logical

那么简单的例子:

if(equals(parameter('x'), 'FAILOVER'), true, false)

这篇关于数据库的Azure ARM故障转移组条件关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 23:13