Skip main navigation

Automation DSC

An introduction to Azure's Desired State Configuration automated options.
16.9
Moving along in our view of Azure automation, we’re going to take a look at Azure automation for desired state configuration. This is built on the exact same technology that is used in Windows Server. So if you’re familiar with Windows Server desired state configuration, then what you do in Azure is literally no different. You can take a desired state configuration script that you’ve written to run on-premise and put that directly into Windows Azure in an automation account. You can author these in Azure directly or you can author them in Windows PowerShell or Windows PowerShell ISE. What Azure does is Azure provides the role of being the DSC pull server.
64.1
It provides the location where the compiled DSC items are placed and then assigned out to individual virtual machines. So as a very quick– to give this a little bit of context, I have what are called DSC configurations and what are called DSC nodes. DSC configurations are PowerShell scripts that I’m going to upload that represent definitions that I want to use. So for example, I’ve got a little Scripts folder in here, and I’ve got an Azure DSC configuration. And this is just a PowerShell file. And if I look at that PowerShell file in PowerShell ISE– I’m going to open that up here.
117.9
You can see that this is a very basic DSC configuration that essentially puts a web server and the binaries for Chocolatey on whatever virtual machine or whatever host this configuration is applied to. So I can take this configuration as a powerful script, upload it into Azure, and then once it’s uploaded, there’s a bit of– you’ve got to upload it. It’s got to be compiled. It’s got to be published. So there’s a few other steps. I can then come out here and assign it to a virtual machine. So OK. I say, hey, Azure. You’ve got this desired state definition. Put this definition on an individual virtual machine.
157.8
The number of virtual machines that you can add in here depends on the level of your automation account. When you add Azure automation, you’re initially put in at a free tier. If you want to manage many, many hundreds of virtual machines with DSC, you’ve got to increase your Azure billing tier so that you can get more DSC nodes. The default for the free tier I think is five DSC nodes.
186.4
So it’s through that basic process that you can write DSC scripts, upload them to Azure, and then Azure will do all the work of applying that configuration to whatever virtual machine that you target it to. So here’s the configuration. You then have a node definition. And then Azure takes care of applying that to however many virtual machines that you want. So let’s walk through the entire process of applying DSC to a running virtual machine using Azure.

In the previous step, we demonstrated using ARM templates to deploy objects in Azure. In this step, we will introduce the concept of a Desired State Configuration.

Azure Automation Desired State Configuration (DSC) is a cloud-based solution for Windows PowerShell DSC. The solution lets you manage, deploy and enforce configurations for physical or virtual machines. Automation DSC uses declarative Windows PowerShell syntax to define your configurations. A centralised pull server retrieves and applies configurations to a set of computers (also known as target nodes).

Use Cases

The following are some example scenarios where you can use built-in DSC resources to configure and manage a set of target nodes in an automated way:

  • Enabling or disabling server roles and features.
  • Managing files and directories.
  • Starting, stopping and managing processes and services.
  • Deploying new software or software updates.
  • Fixing a configuration that has drifted away from the desired state.

Note: If you are not familiar with DSC, take some time to read Windows PowerShell Desired State Configuration Overview

How Automation DSC Works

Three blocks are shown. The first is the Configuration for SharePoint shown in code format. An arrow, labelled ‘Compiled, put on pull server (via compilation jobs)’, connects it to the second block. The second block is labelled “Node Configurations (.MOF configuration documents) and shows three blue blocks stacked on top of one another. An arrow, labelled “Applied (via node push)”, connects it to the third block. This third and final block is labelled Nodes, and shows six computer towers.

  1. Create a PowerShell script with the configuration element.
  2. Upload the script to Azure Automation and compile the script into a Managed Object Format (MOF) file. The file is transferred to the DSC pull server.
  3. Define the nodes that will use the configuration.
This article is from the free online

Microsoft Future Ready: Fundamentals of DevOps and Azure Pipeline

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education