Quantcast
Channel: Fabric Controller» Windows Azure Virtual Machines
Viewing all articles
Browse latest Browse all 15

Migrating your Microsoft Azure Virtual Machine to a different subnet with the new PowerShell Cmdlets

$
0
0

In the past you had to redeploy your Virtual Machine when you wanted to change the subnet in which the machine was deployed. There could be a few reasons why you would need to change the subnet for a VM: the subnet was getting full, a change in the way you structure your Virtual Machines over different subnets, … The latest version of the Microsoft Azure PowerShell Cmdlets (released April 3rd) allow you to move your Virtual Machine to a different subnet without having to redeploy your Virtual Machine.

Let’s look at an example where I have an application running on a VM. This VM resides in the “Servers” subnet because at that time there was no need to have multiple subnets:

Now since my application is growing I’m thinking about splitting things up. My database should be moved to a different server and I might want to split my application over multiple tiers. So I’ll end up with a frontend and a backend. The first thing I do is create the 2 subnets in addition to my existing “Servers” subnet:

The WFE subnet would be the place where I put my webservers, so it’s obvious this is where I want my webserver01 machine to be. And with the new Microsoft Azure PowerShell Cmdlets this is fairly easy to achieve. I simply need to grab my VM, call Set-AzureSubnet, update the VM and in a matter of seconds my VM has been migrated to a different subnet:

Here is the very short code sample:

$context = Get-AzureVM -ServiceName contosomed -Name webserver01
Set-AzureSubnet -SubnetNames "WFE" -VM $context
Update-AzureVM -ServiceName contosomed -Name webserver01 -VM $context.VM

And that’s all there is to make it work! Restructuring your network is much easier now, also allowing you to better protect your subnets using ACL feature available for your VM endpoints.

Enjoy!


Viewing all articles
Browse latest Browse all 15

Trending Articles