azure - 有没有办法使用 Bicep 获取在 Azure SQL Server 防火墙中配置的多个不相关的 IP 地址?

标签 azure azure-sql-database azure-bicep infrastructure-as-code

我希望使用 Bicep 模板将 MS Azure SQL Server 防火墙的多个 IP 地址列入白名单。我已经配置了 SQL Server 模块,现在我想添加/配置firewallRules 资源。我已将 JSON 参数文件用于其他 Bicep 模块。我想知道是否有任何使用 Bicep 代码或 JSON 参数的示例。 Microsoft 提供的模块如下,它配置为单个 IP 地址范围:

资源符号名称 'Microsoft.Sql/servers/firewallRules@2022-05-01-preview' = { name: 'string' 父级: resourceSymbolicName 属性: { endIpAddress: 'string' startIpAddress: 'string' } }

尝试添加多个参数文件,语法/模板似乎是错误的。想知道这里的最佳实践是什么。

最佳答案

将参数定义为数组并使用 for 循环创建多个资源实例:

param firewallRules array

resource SqlServerAllowFirewall 'Microsoft.Sql/servers/firewallRules@2022-05-01-preview' = [for rule in firewallRules: {
  name: rule.name
  parent: SqlServer
  properties: {
    startIpAddress: rule.start
    endIpAddress: rule.end
  }
  dependsOn: [
    SqlServer
  ]
}]
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "firewallRules": {
        "value": [
        {
          "name": "AllowAllWindowsAzureIps",
          "start": "0.0.0.0",
          "end": "0.0.0.0"
        },
        {
          "name": "AllowSomething",
          "start": "1.0.0.1",
          "end": "1.0.0.1"
        }
        ]
      }
    }
  }
}

关于azure - 有没有办法使用 Bicep 获取在 Azure SQL Server 防火墙中配置的多个不相关的 IP 地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75010578/

相关文章:

sql-server - 不使用 Azure 数据同步同步两个 Azure 数据库

azure - 如何确定Azure中应用程序服务计划CPU百分比90%的原因?

sql - 在 SQL Azure 中调试存储过程的方法?

azure - Bicep/ARM 创建存储帐户,其端点链接到已创建的 A 记录的现有 DNS 区域

azure - 如何在 ARM Bicep 模板中添加条件?

Microsoft 托管代理和并行作业上的 Azure 计费

Azure 策略定义权限错误 : AuthorizationFailed

azure - 纵向扩展和横向扩展应用服务计划之间的区别

azure-sql-database - 如何使用 sqlpackage.exe 通过覆盖 azure 数据库上传(导入)