Skip main navigation

New offer! Get 30% off your first 2 months of Unlimited Monthly. Start your subscription for just £35.99 £24.99. New subscribers only T&Cs apply

Find out more

Automation DSC

An introduction to Azure's Desired State Configuration automated options.
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.
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.
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.
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.
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

  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

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now