Reputation: 351
I want to be able to run a script on each deployed VM in Azure that depends on the VM's public IP address.
Is there any way, from the shell, that I could curl some URL, or run the command line interface, or do anything, really, to find this information?
Upvotes: 3
Views: 4465
Reputation: 12228
Taken from here
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
That will get you your public, outgoing IP address.
I have previously configured a small API App that has credentials to Azure Subscriptions that searches through the subscriptions for the IP Address and returns a JSON document with some pertinent configuration. (and complained a little that AWS gives you this stuff for free!)
Upvotes: 10
Reputation: 1275
I keep shortcuts like this in my gists, which is pasted here:
azure vm show <RG_GROUP> <VM_NAME> |grep "Public IP address" | awk -F ":" '{print $3}'
This should give you the public IP address attached to the machine.
Note: I have not tested it with multiple public IPs attached to a single machine. This only covers the basic use case.
Upvotes: 1