简体   繁体   English

如何在ARM模板输出中获取Azure VM的FQDN

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

Following is my template to create Public IP address. 以下是我创建公共IP地址的模板。 Now I want to get the output of fqdn for PublicIPAddress. 现在我想获取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))]"
    }
  }

When I deploy the above template, I see the following error 当我部署上面的模板时,我看到以下错误

        "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}"

I am able to solve this issue by updating the else condition in fqdn outputs section and it works well. 我能够通过更新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