Introduction to Azure Automation
Azure Automation: Runbooks
Azure Automation: Desired State Configuration (DSC)
The first thing you'll need to do, to get started using Azure Automation Desired State Configuration (DSC), is to upload your PowerShell DSC configurations to your Azure Automation Account. Once you've uploaded the DSC configurations, you'll invoke a "compilation job," that compiles your PowerShell DSC configuration document into "node configurations." These node configurations are simply the MOF files that are generated for each of your managed nodes. After this, you'll need to "onboard" (register) your managed nodes with Azure Automation DSC, so you can associate the node configurations with each node.
Hello. In this demonstration, we're going to create a PowerShell DSC configuration document and upload it to our Azure automation account.
As you can see in the Microsoft Azure portal here under our automation accounts blade, we have the DSC configurations button that allows us to view any DSC configurations that have been uploaded to the account. As of this moment, we don't have any DSC configurations uploaded, so let's go ahead and create one. I'm going to switch over to the PowerShell integrated scripting editor here, and you'll see that I've already built the basic framework for a DSC configuration.
When you're creating a DSC configuration, it's important to note that currently the Microsoft Azure portal does not allow you to specify configuration data separately from your configuration document. However, you can use the Azure PowerShell module to combine your configuration data and to the configuration document when you upload it to the Azure automation account. In this case, I have a single configuration called Contoso. I have a parameter block that's empty, so I'm not accepting any input parameters. I have a single node block that statically specifies a computer name, and then I have a single DSC resource to find in there, that will simply create a text file called CloudAcademy.text in the C windows folder.
Now let's go ahead and upload this DSC configuration to Azure automation. I'll switch back over to the portal and click add a configuration. Under the configuration file, I'll just browse to the DSC configuration file. As you can see, Azure automation was automatically able to discern the name of the configuration itself inside that file. I'm also going to specify a description to help other administrators under the purpose of this DSC config. Great. Now I'll click the okay button, and the Azure portal will import our DSC configuration.
Now that the DSC configuration has been published, we need to generate the node configurations, which are the MOF files that are compiled from the PowerShell DSC config. To compile the node configurations, I'll click on the DSC configuration and when the blade opens up for that configuration, you have a compile button. Under compilation jobs, you'll see that we have not, so far created any compilation jobs for this DSC configuration. So I'll click the compile button and click yes, I do want to compile it.
So, the Azure portal has now submitted a new job to compile that configuration into node configurations. Under the compilation jobs, you'll see that a new job has been queued. If we click on that job, a new blade will open up in the Azure portal that will show us the detailed status of that compilation job. The compilation job has now completed, so we now have node configurations available to us.
Let's go ahead and head back over to the Azure automation account blade, and under the DSC node configuration button, you'll see that we have a single node configuration available. The name of the node configuration is the configuration document's name, followed by a period, and then the node name that will be managed by it.
Now, we need to assign this node configuration to a node. So, we'll click over on DSC nodes, we'll choose the node that we've already onboarded, and then we'll click on the assign node configuration button. We'll be prompted with a list of node configuration so we'll choose the one that's appropriate for that machine, and then click okay.
Under the node's blade, you'll see that it now has a configuration and node configuration assigned to it successfully. The next time that this virtual machine's local configuration manager checks in with Azure automation, it will download the latest configuration and process it locally.
Trevor Sullivan is a Microsoft MVP for Windows PowerShell, and enjoys working with cloud and automation technologies. As a strong, vocal veteran of the Microsoft-centric IT field since 2004, Trevor has developed open source projects, provided significant amounts of product feedback, authored a large variety of training resources, and presented at IT functions including worldwide user groups and conferences.