Set Azure VM Static IP Address
Set static IP addresses for Windows Azure IaaS virtual machines.
March 4, 2014
Q: How do I set a static IP address for a virtual machine (VM) in Windows Azure IaaS?
A: Prior to Windows Azure PowerShell 0.7.3.1, it wasn't possible to give a VM in a virtual network subnet a static IP address that persisted even if the VM was deprovisioned (shutdown from the portal) and therefore no long billed for.
The only option was to create different virtual subnets for different groups of VMs to try and control the IP address the VM would be given from Windows Azure.
RELATED: Video: Using Static IP Addresses in Azure
The Virtual Network static IP feature is now available through PowerShell (0.7.3.1 and later), which is available at the Window Azure website. This enables a static IP to be assigned to a VM that will persist with the VM, even if it's deprovisioned. The VM must be within a virtual network to have a static IP address configured. There are four cmdlets used:
Set-AzureStaticVNetIP - Sets a static IP address, e.g. Set-AzureStaticVNetIP -VM -IPAddress
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 -IPAddress
As a best practice, don't mix VMs using static IP addresses with VMs using DHCP within a subnet. Instead, create dedicated subnets within the virtual network that will be used for VMs using static IP addresses. Below is an example of these cmdlets in action in my environment, but this won't actually take effect until the Windows Azure region you're using has implemented this functionality:
PS C:> Test-AzureStaticVNetIP -VNetName SavTechNet115 -IPAddress 10.7.115.51IsAvailable : FalseAvailableAddresses : {10.7.115.52, 10.7.115.53, 10.7.115.54, 10.7.115.55...}OperationDescription : Test-AzureStaticVNetIPOperationId : c6f70cc4-bf36-7907-9c7e-bc1c2e925cbbOperationStatus : SucceededPS C:> Test-AzureStaticVNetIP -VNetName SavTechNet115 -IPAddress 10.7.115.55IsAvailable : TrueAvailableAddresses : {}OperationDescription : Test-AzureStaticVNetIPOperationId : 30d13740-42a3-724a-8dc8-0f418a6a6af9OperationStatus : SucceededPS C:> $staticVM = Get-AzureVM -ServiceName savnetazu115 -Name TestStaticVMPS C:> Set-AzureStaticVNetIP -VM $staticVM -IPAddress 10.7.115.55 | Update-AzureVMPS C:> Get-AzureStaticVNetIP -VM $staticVMIPAddress --------- 10.7.115.55
I walk through this whole process in my video Using Static IP Addresses in Azure.
About the Author
You May Also Like