Reputation: 486
I am trying to build a multi-machine vagrant script using vagrant\azure provider. Building the machines under a cloud service is pretty straight forward. However, I am in need to run a bash script to do some provision tasks once the machines are up. In those bash scripts I need to know the IP address (the private IP address of the VM, not the virtual IP).
My understanding (please correct me if I am wrong) is I can't really set private IP to VM instances (even If I define a range in a virtual network, it doesn't guarantee the exact IP ), so I need to know them some how once the machine is created. and before executing the script.
How can I do that? Any suggestions are greatly appreciated.
Upvotes: 1
Views: 358
Reputation: 1384
It is possible to request a static IP address for an Azure virtual machine that is being set up in an Azure virtual network using the techniques shown in this Azure documentation: Set a Reserved Private IP Address for a VM, and in this blog post: Setting Static IP Addresses in a Virtual Network. The solution requires that you are using Azure PowerShell.
The node.js-based Azure command line tool will permit manipulation of a VM's static IP address. Try
azure vm static-ip --help
for more information.
If the VM is running a UNIX variant, obtaining the internal IP address that a VM was assigned can be done by running the ifconfig
or ip
commands and parsing the results as shown in this unix.stackexchange.com answer.
Upvotes: 2