2

Have a ARM template (https://github.com/jmspring/arm-template-neo4j-docker/blob/master/azuredeploy.json) which will launch a instance and assign a public IP.

here i need to print the IP address as Output. i tried adding the following to the template. but still it it does not print the value.

"outputs": {
"ipaddress": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName')),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).ipAddress]"
  },

"VM IP address": {
  "type": "string",
   "value": "[reference(variables('publicIPAddressName')).ipAddress]"
 }
}
}

Any assisance will be helpful.

3

I have seen this a couple of times before. If you want to get the IP address immediately, then you need to use static for the "publicIPAllocationMethod" property.

If you do not want to use static (Reserved IPs), then you need to put a dependency on the Virtual Machine that is attached to the Public IP (the address will be allocated then).

Just for reference as well, for private IP addresses you can use the following to return the private IP address if this is also required:

reference('nic-name').ipConfigurations[0].properties.privateIPAddress
  • 1
    i can retrieve private address using the nic details but finding difficulty while fetching dynamically assigned IP. – Boobalan A Apr 6 '16 at 17:46
  • 1
    That's correct, as I said you can only retrieve the IP address when it's set to static not dynamic. – Martyn C Apr 7 '16 at 7:32
  • Keep in mind that when you use the reference() function, if the resource isn't located in the same template you'll need to supply the resource ID using something like reference(resourceId(parameters('resourceName'))) github.com/Azure/azure-quickstart-templates/blob/master/… – cody.codes Nov 16 '18 at 17:12
3

Answer really comes from Azure docs

"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))).IpAddress]",

Get fancy and construct SSH login string with username:

     "Public IP SSH": {
    "value": "[concat(
        reference(resourceId('Microsoft.Compute/virtualMachines',variables('vmName'))).osProfile.adminUsername,
        '@',
        reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))).IpAddress]",
    "type": "string"
 },
  • small mistake here: .IpAddress)]", should be .IpAddress]" – johnstaveley Sep 5 '17 at 12:45
  • (In first section) – johnstaveley Sep 5 '17 at 12:45
  • @johnstaveley good catch - edited – Alec Istomin Sep 5 '17 at 17:42
1

I used this to retrieve the public IP: "[reference(concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))).ipAddress]" . I used "publicIPAllocationMethod" as "static"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.