簡體   English   中英

如何在ARM模板輸出中獲取Azure VM的FQDN

[英]How to get FQDN of Azure VM in ARM template output

以下是我創建公共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}"

我能夠通過更新fqdn輸出部分中的else條件來解決這個問題,並且它運行良好。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM