Microsoft Azure: find public ip from command line of created instance

I want to be able to run a script on every VM deployed in Azure that depends on the VM's public IP.

Is there any way from the shell so that I can twist some url, or start a command line interface, or do something really to find this information?

+3


source to share


2 answers


Taken from here

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'  

      



This will give you your public outgoing IP address.

I previously set up a small API application that has credentials for Azure subscribers that browse IP subscriptions and return a JSON document with some related configuration. (and complained a bit that AWS gives you this stuff for free!)

+4


source


I keep shortcuts like this in my gists, which is inserted 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 the same machine. This only applies to the main use case.

+1


source







All Articles