Configuring static IP addresses on Azure VM’s

I’ve been doing a lot of Azure IaaS lately and got some things to share. This is the first of multiple posts about Azure VM’s and such.

Microsoft has recently added the ability to set static IP addresses on VM’s created in Azure. Some things you should be aware of:

  • You can only set a static IP address using PowerShell, not the Azure portal (for now at least..)
  • The IP address is set when you create the VM – you cannot change it afterwards or on an existing VM
  • You need at least version 0.7.3.1 of the Azure command-line tools, you can get the newest version here: http://www.windowsazure.com/en-us/downloads/

So, how is this done?

Simple: Use Set-AzureStaticVNetIP when creating your VM. Example:

[powershell]$vmName = "TESTVM1"
$vmSize = "Small" #ExtraSmall, Small, Medium, Large, ExtraLarge, A6, A7
$imageName = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201403.01-en.us-127GB.vhd" #Use Get-AzureVMImage to list the available images
$domainAdmin = "jj-admin"
$domainAdminPw = Read-Host "Enter domain admin password:"
$domain = "domain"
$domainFqdn = "domain.com"
$localAdmin = "jj"
$localAdminPw = Read-Host "Enter local admin password:"
$subnet = "BackEndSubnet"
$ipAddress = "10.1.1.10"
$serviceName = "jjlab"

$vm = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -ImageName $imageName
$vm | Add-AzureProvisioningConfig -WindowsDomain `
-AdminUsername $localAdmin `
-Password $localAdminPw `
-DomainUserName $domainAdmin `
-DomainPassword $domainAdminPw `
-JoinDomain $domainFqdn `
-Domain $domain
$vm | Set-AzureSubnet -SubnetNames $subnet
$vm | Set-AzureStaticVNetIP -IPAddress $ipAddress
New-AzureVM -VMs $vm -ServiceName $serviceName[/powershell]

Currently there is no way to avoid passwords in plain text. Hopefully this will be added soon.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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