Using Azure Desired State Configuration – Part IV

So we’ve talked about Azure Automation DSC and the extensive reporting we can get from it.  With the pricing as it is, it would be hard to argue as to why you would want to use anything else.  But I’m a completionist, and there may be some edge cases that might come up where you wouldn’t be able to use the pull method for configurations.  So let’s talk about how you can use Azure DSC to push a configuration to a virtual machine.

So let’s get started!

Publish the Configuration

In order to push a configuration, we need to publish it to a blob store.  When you use Publish-AzureRmVmDscConfiguration, the command bundles all of the required modules along with the configuration into a .zip file. It does this by pulling the modules from your local machine that you’re running the command from, so you’ll need to make sure that you have the appropriate modules installed on your system.

First, we’ll go ahead and grab a storage account where these binaries can be published.  In the storage account, we have a blob store for our configurations.  This blob store is a private store.

Now that we have our private store, we’re going to publish our configuration using the Publish-AzureRmVMDscConfiguration command.

As previously mentioned, the command reads your configuration, and then grabs the necessary modules from your local machine and adds them to the package when it publishes the configuration.  This way, the machine has all of the necessary bits to perform the configuration.  You can actually validate this by downloading the packaged .zip file from the blob store and seeing for yourself.

Along with the modules and configuration, you’ll also find a dscmetadata.json file that is essentially a manifest of the required modules.

Install the VM Extension

Now that our binaries have been published, we can get our target machine and deploy the Azure DSC VM extension to it while assigning the configuration.  When you deploy the extension, it’s best to use the latest version available.  If you want to check which version is the latest, you can check out the release history on the PowerShell Team Blog.

Like with Azure Automation DSC, when you register the VM extension, your PowerShell session will be held open until the extension returns a success or failure status.  Once it returns, you can check the status of the configuration using Get-AzureRmVmDscExtensionStatus.

If you want to dive a little deeper, we can of course grab the specific DscConfigurationLog information:

As you can see, the configuration is complete pending a reboot.  This brings us to a few of the caveats associated with the push method for Azure DSC.

  • Unfortunately, unlike with the Register-AzurRmAutomationDscNodeConfiguration command available for Azure Automation, you cannot currently configure the LCM direct from the command.  Instead, you’ll want to add a LocalConfigurationManager block to your top level config to set any attributes for the LCM.
  • As the system is downloading the packaged modules and configuration files, the mof file is configured locally on the machine.  While the current.mof file is encrypted, there is a copy of the mof that is generated in the C:\Packages\Plugins\Microsoft.Powershell.DSC\<pluginVersion>\<configuration>\ directory.  You’ll want to be careful as to what you’re passing in plain text in that regard.
  • You can retrieve the DscConfigurationLog data for validation of your configs and the state of the machines, but this process requires automation and can take some time to compile.

So now we’ve explore Azure Desired State Configuration using the available push and pull methods.  And we’ve explored the rich reporting capabilities that are available to you in Azure Automation DSC.  It’s been a long journey, but I hope you’ve found this content to be useful to you!

Until next time!