0

我正在尝试在 Azure 私有 DNS 区域中使用ARM template. 记录创建成功,但没有 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 记录的屏幕截图: 在此处输入图像描述

任何的想法?

4

2 回答 2

0

我认为您有比赛条件。添加一个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"
          }
        ]
    }
  }
]
于 2021-10-28T23:50:39.540 回答
0

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

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

但问题是,当它用大写字母编写时,REST API 不会抛出错误并接受请求。通常,它应该返回 http 400 错误。

无论如何,我的问题解决了。

于 2021-11-02T16:57:40.560 回答