Setting Static IP address on Windows Azure
Use PowerShell command to assign Static IP for Azure. The command we will be using to assign the Static IP address is called as Set-AzureStaticVnetIP
By running this command what it does is, it is setting a DHCP Reservation for the Virtual Machine. Meaning, inside our Virtual Machine, the network adapter will be still configured as DHCP client, but it will be assigned with a single IP always even after booting the VM.
Now, let’s see how to assign static IP on Windows Azure. We need a special PowerShell for Azure & it can be downloaded from this link: http://azure.microsoft.com/en-us/downloads/. Next scroll down to command-line tools => Click on Windows install under Azure command-line interface. After this you will see the Windows Azure PowerShell under the start menu. Post this we can follow the below steps to assign Static IP Address on Windows Azure.
Step 1: Launch the Windows PowerShell Azure. Then type Add-AzureAccount & enter the email address that you have used for activating your license.
Step 2: Next we will get the publish settings file, this file contains credentials & other information used on Azure. We have to save the .Publish Settings file to a location & then run the below command, to import the settings file to PowerShell.
Import-AzurePublishSettingsFile <PathToFile>
Step 3: After completing with the above steps, we can run the below command to get the details of our ServiceName (domain) & the Virtual Machine name that will be required to run other commands.
Get-AzureVM
Step 4: Next we have to assign static IP to the VM. First we need to stop the running VM by running the following command:
Get-AzureVM -ServiceName msexchangeguru | Stop-AzureVM –Force
Then run the below commands to assign Static IP address:
Get-AzureVM -ServiceName msexchangeguru -Name AZ-VM1 | Set-AzureStaticVNetIP -IPAddress “10.0.0.5″ | Update-AzureVM
Get-AzureVM -ServiceName msexchangeguru -Name AZ-VM1 | Set-AzureStaticVNetIP -IPAddress “10.0.0.6” | Update-AzureVM
“Update-AzureVM” command is very important as the changes won’t be saved without it. Also remember that when you run “Update-AzureVM” command it will restart your VM & you will lose connectivity. It’s better to perform this change during planned maintenance time.
Step 5: You can now launch the Azure Management portal to view the Static IP address that was just assigned.
Additional Commands that are available to test, remove, get Static IP addresses in Azure:
Set-AzureStaticVNetIP – Sets a static IP address, e.g. Set-AzureStaticVNetIP -VM <VM> -IPAddress <IP address string>
Get-AzureStaticVNetIP – Gets the static IP address of the passed VM
Remove-AzureStaticVNetIP – Removes the static IP address of the passed VM
Test-AzureStaticVNetIP – Checks to see if a certain static IP address is available from a virtual network, e.g., Test-AzureStaticVNetIP -VNetName <network name> -IPAddress <IP address string>
Update-AzureVM – Commits the changes made & restarts the Virtual Machine
Ratish Nair
Microsoft MVP | Exchange Server
Team @MSExchangeGuru.com
August 8th, 2015 at 7:46 pm
[…] Setting Static IP address on Windows Azure […]
August 8th, 2015 at 7:49 pm
[…] Setting Static IP address on Windows Azure […]
August 14th, 2015 at 9:29 am
Hi,
Great post!
I’ve carried out the same to set static IPs a lot recently and it does exactly that!!