2

Following is my template to create Public IP address. Now I want to get the output of fqdn for PublicIPAddress.

  "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}"
Galet
  • 5,853
  • 21
  • 82
  • 148
  • The DNS name is always vmname.region.cloudapp.azure.com so you could technically just create this by concatting the parts together from your parameters. – ranieuwe Aug 31 '18 at 13:10
  • 1
    I want to fetch it dynamically. Is there a way to do it – Galet Aug 31 '18 at 13:12

1 Answers1

4

I am able to solve this issue by updating the else condition in fqdn outputs section and it works well.

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