With the advent of Microsoft Azure (formerly Windows Azure) in 2010, engineers and developers were given the ability to build virtual environments to suit their many needs, in a Microsoft hosted solution. Azure offered a dynamic environment for development and testing, while at the same time allowing for the effective management of costs.
In order to further contain the expense of working in Azure, developers will often stop or “de-allocate” a virtual machine when they have no more tasks involving it. Only when the virtual machine is required, will it be started again. This practice works well in applications that only require a single virtual machine, but what if you have the need to use several?
Multiple virtual machine environments are often created within an Azure Virtual Network and given their own subnet of IP addresses. The IP addresses are allocated dynamically, and as you well know, dynamic IP addresses in a development environment can, and most certainly will, wreak havoc. To circumvent this problem, Azure developers are forced to start each virtual machine in a specific order to ensure that IP addresses are allocated properly for the functionality of their projects.
Recently, the Windows Azure team has included the ability to assign static IP addresses for Azure virtual machines. Below, I detail the basic method to accomplish this, but there is a caveat. If an IP address you wish to assign as “static” has already been allocated or is currently in use, this method will fail. You must ensure that all static IP addresses are freely available.
To accomplish the task of requesting a static IP address, you must first download and install the Windows Azure Powershell. This is done via the Microsoft Web Platform Installer.
After the installation of the Azure Powershell, run the application.
< a href=”http://i.imgur.com/n16VUqs.png”> Windows Azure Powershell
Login to your Azure account with the command
This will open a windows login dialog that will allow you to enter your credentials.
Windows Azure Login
Now you need to find the name of the subscription you created your virtual machines under. The command is:
The output will look similar to below.
Azure subscription information
In my case, I will use Visual Studio Ultimate with MSDN. The command to select this is:
Select Azure Subscription
Enter your subscription name and then ENTER:
Enter Azure Subscription Name
At this point you are connected to your subscription and can begin to work with the virtual machines created under it.
There are two parameters you will need to have:
And finally the commands, there are three.
Get-AzureVM -ServiceName <your_vm_name> -Name <your_vm_name>
Set-AzureStaticVNetIP -IPAddress "<your_new_ip_address>"
Unfortunately, entering these commands one at a time fails. They must be strung together via “pipes”.
Get-AzureVM -ServiceName <your_vm_name> -Name <your_vm_name> | Set-AzureStaticVNetIP -IPAddress "<your_new_ip_address>" | Update-AzureVM
As an example:
Get-AzureVM -ServiceName HST-Test01 -Name HST-Test01 | Set-AzureStaticVNetIP -IPAddress "192.168.224.50" | Update-AzureVM
In the event that you need to remove an assigned IP address, use the following command structure.
Get-AzureVM -ServiceName <your_vm_name> -Name <your_vm_name> | Remove-AzureStaticVNetIP | Update-AzureVM
More on Azure cmdlets can be found at:
This method has proven invaluable in providing us the ability to more simply manage our Azure virtual machines as a team. Please take the time to review the links above to gain insight into other Azure Powershell commands.
And don’t forget to comment!
I am a technical architect with Discover Technologies based in the Washington, DC metro area. My areas of expertise lie in search solutions (HP/Autonomy, Microsoft Fast), SharePoint, performance testing, and linux.