无法使用 ARM 模板创建带有其 ip 的 azure private dns A 记录

Cannot create azure private dns A record with its ip by using ARM template

我正在尝试使用 ARM template 在 Azure 私有 DNS 区域中创建 A 记录。记录创建成功,但没有 IP,也没有 TTL。 我的模板如下:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "DNSZoneName": {
      "type": "string",
      "defaultValue": "privatelink.database.windows.net",
      "metadata": {
        "description": "The name of the DNS zone. Must have at least 2 segements, e.g. hostname.org"
      }
    },
    "newRecordName": {
      "type": "string",
      "defaultValue": "pe-sql3",
      "metadata": {
        "description": "The name of the DNS record to be created. The name is relative to the zone, not the FQDN."
      }
    }
  },

  "resources": [
    {

      "type": "Microsoft.Network/privateDnsZones/A",
      "apiVersion": "2018-09-01",
      "name": "[concat(parameters('DNSZoneName'), '/', parameters('newRecordName'))]",
      "location": "global",
      "properties": {
        "TTL": 3600,
        "ARecords": [
          {
            "ipv4Address": "10.0.0.1"
          }
        ]
      }
    }

  ]
}

我的命令是New-AzResourceGroupDeployment -ResourceGroupName myRg -TemplateFile deploy.json

传送门A记录截图如下:

有什么想法吗?

我认为你有竞争条件。添加一个 dpendsOn.

  "dependsOn": [
    "[parameters('DNSZoneName')]"
  ],

像这样: [编辑:同时指定 DNS 区域资源]

"resources": [
{
  "type": "Microsoft.Network/privateDnsZones",
  "apiVersion": "2018-05-01",
  "name": "[parameters('DNSZoneName')]",
  "location": "global"
},
{
    "type": "Microsoft.Network/privateDnsZones/A",
    "apiVersion": "2018-09-01",
    "name": "[concat(parameters('DNSZoneName'), '/', parameters('newRecordName'))]",
    "location": "global",
    "dependsOn": [
        "[parameters('DNSZoneName')]"
    ],
    "properties": {
        "TTL": 3600,
        "ARecords": [
          {
            "ipv4Address": "10.0.0.1"
          }
        ]
    }
  }
]

我正在用大写字母写 TTL 和 ARecords。那应该是 ttlaRecords:

    "properties": {
        "ttl": 3600,
        "aRecords": [
            {
                "ipv4Address": "1.2.3.4"
            }
        ]
    }
}

但问题是,当它用大写字母书写时,REST API 不会抛出错误并接受请求。正常应该returnhttp 400错误。

总之我的问题解决了