【问题标题】:How to get FQDN of Azure VM in ARM template output如何在 ARM 模板输出中获取 Azure VM 的 FQDN
【发布时间】:2018-08-31 13:03:24
【问题描述】:

以下是我创建公共 IP 地址的模板。现在我想为 PublicIPAddress 获取 fqdn 的输出。

  "name": "[variables('publicIPAddressName')]",
  "type": "Microsoft.Network/publicIpAddresses",
  "apiVersion": "2018-06-01",
  "location": "eastus",
  "properties": {
      "publicIpAllocationMethod": "Static",
      "dnsSettings": {
      "domainNameLabel": "mycompany"
      }
   }

  "outputs": {
    "fqdn": {
      "type": "string",
  "value": "[if(equals(parameters('serverName'), 'app'), reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))).dnsSettings.fqdn, json(null))]"
    }
  }

当我部署上述模板时,我看到以下错误

        "message": "{\r\n  \"error\": {\r\n    \"code\": \"InvalidTemplate\",\r\n    \"message\": \"Deployment template validation failed: 'The template output 'fqdn' at line '259' and column '13' is not valid: Unable to parse language expression 'if(equals(parameters('serverName'), 'paxata'), reference(variables('publicIPAddressName')).dnsSettings.fqdn, json(null))': expected token 'LeftParenthesis' and actual 'RightParenthesis'.. Please see https://aka.ms/arm-template-expressions for usage details.'.\"\r\n  }\r\n}"

【问题讨论】:

  • DNS 名称始终为 vmname.region.cloudapp.azure.com,因此从技术上讲,您可以通过将参数中的部分连接在一起来创建它。
  • 我想动态获取它。有没有办法做到这一点

标签: azure arm-template fqdn


【解决方案1】:

我可以通过更新 fqdn 输出部分中的 else 条件来解决这个问题,并且效果很好。

"fqdn": {
  "type": "string",
  "value": "[if(equals(parameters('server'), 'app'), reference(resourceId('Microsoft.Network/publicIPAddresses', 'publicip3')).dnsSettings.fqdn, 'FQDN not available')]"
}

【讨论】:

  • 私网IP能否获取FQDN?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-29
  • 1970-01-01
  • 2020-09-14
  • 2022-08-03
相关资源
最近更新 更多