Managing VM Configurations with Azure Automation DSC

As you can see in the script below, I’m simply referencing the “localhost” machine (the machine the script is running on) and just ensuring that the File-Services feature is present.  It’s a pretty basic script.  I’ve gone ahead and saved the script as FileServerConfig.ps1 on my workstation.

FileServerConfig.ps1
 
  1. Configuration FileServerConfig
  2. {
  3. Import-DscResource -Module 'PSDesiredStateConfiguration'
  4. Node "localhost"
  5. {
  6.       WindowsFeature 'FileServices'
  7. {
  8. Ensure = 'Present'
  9. Name = 'File-Services'
  10. }
  11. }
  12. }

Create an Azure Automation Account

With my configuration script created, I can now go in and start settings thing up.

Before making use of Azure Automation DSC, I first need to provision an Azure Automation account from within my Azure portal.

To create the account, I have to login to my Azure portal and perform the following steps:

  • Click green+ New icon in the left pane
  • Select Monitoring and Management, and then click Automation in the Monitoring and Management
  • In the Add Automation Account pane, enter a name for the new automation account.
  • Select my Azure subscription from the dropdown menu.
  • Check Create New under Resource Group and enter a name for the new group.
    • I could also just add my automation account to an existing Resource Group if I wanted to as well.
  • Select a location from the dropdown menu.
  • Ensure Create Azure Run-As Account is set to Yes.
  • Click Create to deploy my new automation account.

After a few minutes, my Azure Automation Account will be created.  If I browse to “Automation Accounts” in the left pane of my portal, I can confirm that my account has been created.

Add a DSC Configuration to Azure Automation

Now that my Azure Automation account has been provisioned, I can add the FileServerConfig.ps1 DSC configuration script to Azure be performing the following steps:

  • In the DSC Configurations pane, click Add a Configuration.
  • In the Import pane, click the folder icon to browse for a configuration file
  • Select FileServerConfig.ps1 and click OK.
  • Wait for status to change to Published, and then click on the filename in the DSC Configurations pane and click Compile in Configuration pane.

Again, I’ll need to wait a few minutes for DSC script to be compiled into a MOF file.

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.

"