Managing VM Configurations with Azure Automation DSC

NOTE:  Occasionally, Azure will throw the following warning during compilation:

“The 'Microsoft.PowerShell.Management' module was not imported because the Microsoft.PowerShell.Management' snap-in was already imported.”

The above warning can be safely ignored since it is just indicating the snap-in has already been imported.

Onboard an Azure VM

Once my DSC script has been compiled, I can onboard a VM and assign the DSC configuration to it by performing the following steps:

  • Browse to my Automation Account pane and click the DSC Nodes tile
  • In the DSC Nodes pane, click Add Azure VM
  • From the Add Azure VMs pane, click Select Virtual Machines to onboard
  • Select the VMs to on board (ServerA, in this example)
  • In the Add Azure VMs pane, click Configure Registration Data
  • Once in the Registration pane, select the name of the DSC configuration to use from the Node Configuration Name dropdown box
    • In this tutorial, the node name I used is localhost
  • The default settings for Refresh Frequency and Configuration Mode Frequency can be chosen
  • Ensure that ApplyAndAutoCorrect is selected from the Configuration Mode dropdown menu, and click OK
    • You can, instead, select ApplyAndMonitor if you just want to be warned when the config drifts
  • Ensure the selected VM is powered on
  • Browse to the Add Azure VMs pane and click Create

It may take several minutes for the node to show up and may take more time for the configuration to be applied to the node.  Timing is largely dependent on the refresh and configuration mode frequencies that are set.  The minimum Refresh Frequency is 30 minutes and the minimum Configuration Mode Frequency is 15 minutes.

Confirming that things worked is as simple as RDPing into the VM and running the following command in PowerShell:

Click here to join the Understanding Azure Facebook group or here for the latest Azure practice questions, answers, explanations, and reference materials.

Thomas Mitchell

Tom is a 20+ year veteran of the IT industry and carries numerous Microsoft certifications, including the MCSE: Cloud Platform and Infrastructure certification. A Subject Matter Expert in Active Directory and Microsoft Exchange, Tom also possesses expert-level knowledge in several other IT disciplines, including Azure, Storage, and O365/Exchange Online. You can find Tom at his website, on LinkedIn, or on Facebook. Need to reach him by phone? Call 484-334-2790.