I assign a dynamic IP for a VM when I am deploying a template. During or after the creation of VM, is there a way to get the dynamic IP?
Thanks
You can get this information from the ipConfigurations property on the NIC resource reference.
using something like the following
reference('nic-name').ipConfigurations[0].properties.privateIPAddress
The following is from the postgress template and returns the dynamically assigned IP address as an output property, which is then passed as a parameter to another template.
"outputs": {
"masterip": {
"value": "[reference(concat(variables('nicName'),0)).ipConfigurations[0].properties.privateIPAddress]",
"type": "string"
}
}
@trentmswanson Thanks for your response.
Sorry that I did not describe my question clearly. I want to get a dynamic public IP.
https://github.com/Azure/azure-quickstart-templates/blob/master/bosh-setup/azuredeploy.json#L137
I assigned a dynamic public IP to a VM. And for some reason, I want to get this IP in the VM.
privateIPAddress. Is that right?http://www.whereismyip.com. But it is not a right way in the long run.@bingosummer This came up recently in another thread. Here's the reply from @mahthi
If you want to get the IP address immediately, then you need to use “static” for the “publicIPAllocationMethod”
If you don’t 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)
@singhkay Thanks for your help.
AFAIK, network interfaces can use only dynamic public IPs in ARM mode. So I can't assign a static one to it. But I need to get the public IP address inside the VM. I have two choices:
http://www.whereismyip.com.The first way does not work for me. So I choose the second one as a workaround.
@singhkays
If you don’t 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)
Can you please confirm on this? In a normal exported VM ARM template, VM has the dependency on the network interface which has the dependency on the public IP address. It doesn't output the IP address right way from ARM. It takes awhile to get the IP address. If I miss out something, please share me an example ARM template. Thanks.
@michaelsync
Can you please confirm on this? In a normal exported VM ARM template, VM has the dependency on the network interface which has the dependency on the public IP address. It doesn't output the IP address right way from ARM. It takes awhile to get the IP address. If I miss out something, please share me an example ARM template. Thanks.
have you managed to solve this issue?
because it looks like circular dependency - if you try to exclude "publicIP" from NIC, "publicIP" won't attach to VM and so on.
Probably too late, but I remember having done this with a dirty little trick: you use a nested template that depends on the VM, so that it is only triggered when the VM is finished. The nested template will output the ipAddress property of the public IP, and the main/root template will take the output of the nested deployment