Static IPs in Windows Azure

If you’ve used Windows Azure virtual machines, you’ll be aware that virtual machines you create in virtual networks don’t get static IP addresses, they get what is effectively an infinite DHCP lease on an IP address.  That infinite lease only exists as long as your cloud service is running  – if you shut it down and start another virtual machine on that virtual network, it could get that IP address.  For services that are running the entire time this is usually OK, but doesn’t give any predictability, nor does it give you any control over what IP address is allocated.

A new version of the PowerShell cmdlets for Windows Azure was released earlier this year, and in the changelog, four new virtual network cmdlets are added:


These cmdlets haven’t been officially announced as far as I can see, nor are they documented as to their behaviour, but fortunately there is some PowerShell help available.  Even so, it’s taken a bit of playing around to figure out exactly what you are able to do with it.  From what I’ve managed to figure out, you have to use “Set-AzureStaticVNetIP” during provisioning of a new VM, it doesn’t seem to work on existing VM’s, even if they are deallocated/stopped.

Basically, you just add it into your standard VM provisioning PowerShell:

New-AzureVMConfig –Name $name –InstanceSize $size -ImageName $img |
Add-AzureProvisioningConfig -Windows –AdminUserName $admin -Password $pwd |
Set-AzureSubnet –SubNetNames $subnet |
Set-AzureStaticVNetIP -IPaddress |
New-AzureVM -ServiceName $newSvc –vNetName $vnet –AffinityGroup $ag

This will start a new VM, with the desired IP address.  Examining the virtual machine once it’s provisioned shows that the machine is still allocated its IP address via DHCP. It looks like this just creates a static reservation for the VM somewhere in the Windows Azure fabric.

Hopefully Microsoft will document this more fully in time, and maybe even bring the functionality into the Windows Azure portal.  But at least there is now a solution for fixed IP addresses in Windows Azure.  And I’m also making an assumption here that this is going to be supported long term by Microsoft (I feel pretty safe in making that assumption though – this is good functionality).


One thought on “Static IPs in Windows Azure

  1. […] blog: Allocating Static IP Addresses to your VMs Stufox. Static IPs in Windows Azure WindowsITPro Set Azure VM static IP […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s