Windows Azure – Automation of Configuration across VMs

What are the options or tools available if you want to maintain consistent state or configuration to all your VMs in Windows Azure?

The first approach is to use Custom Script Extension. Set-AzureVMCustomScriptExtension command can be used from Powershell to add the Custom Script extension to an existing virtual machine.

However this approach can become inefficient or difficult to manage in a scaled environment with large number or different groups of VMs. Automation Desired State Configuration (DSC) can be used in such scenarios to set and maintain consistent configurations and states across all your VMs. You configure them and DSC push these to all nodes.

DSC extends PowerShell with ‘Configuration’ syntax with which you can set all the required configuration details for nodes.

Configuration SampleDSCConfig 
{
 Node "MyNode1" 
 {
 #Enable IIS
 WindowsFeature IIS 
 {
 Ensure = "Present"
 Name = "Web-Server"
 }

 #Install ASP.NET 4.5
 WindowsFeature ASP
 {
 Ensure = “Present”
 Name = “Web-Asp-Net45”
 }
 }
}

DSC can be used to perform many practical tasks/configurations across VMs such as:

• Setting server roles and features
• Registry settings
• Files and directories
• Start/stop processes and services
• Manage user accounts
• Deploy software
• Run Windows PowerShell scripts
• Managing environment variables
• Fix configuration drifts

Given below is another example of setting a registry value:

Configuration SampleDSCConfig 
{
Node "MyNode1" 
{
 Registry DisableShutdownTracking
 {
 Ensure = "Present"
 Key = "HKEY_LOCAL_MACHINE\SOFTWARE\...."
 ValueName = "MyValueName"
 ValueData = "0"
 ValueType = "Dword"
 Force = $true
 }
}
}

For advanced configuration and management of your scaled VM infrastructure, you can also use CM tools such as Puppet and Chef which will be described in another blog.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s