It is possible to assign a static IP to a virtual machine in Microsoft Azure but not in the traditional manner. It’s more like creating a DHCP reservation for the VM so you will have to leave the adapter setting to “Obtain an IP address automatically”.
The process for creating a static IP reservation in Azure is given below:
Open the Windows Azure Powershell and connect to the Azure subscription
- Get-AzurePublishSettingsFile
- Import-AzurePublishSettingsFile <FILE NAME AND PATH>
Check to see if the IP address that you want to statically assign is available
- Test-AzureStaticVNetIP -VNetName <YOUR NET NAME> -IPAddress <IP ADDRESS>
Identify the virtual machine name and store it into a variable
- $staticVM = Get-AzureVM -ServiceName <CLOUD SERVICE NAME> -Name <VM NAME>
Create the static reservation
- Set-AzureStaticVNetIP -VM $staticVM -IPAddress <IP ADDRESS> | Update-AzureVM
The virtual machine will now reboot and will retain this IP from now on. I hope you found this post useful and easy to follow!