Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Automation Desired State Configuration (DSC)

A demonstration of the someone utilising some of the DSC options discussed previously

In the previous step, we discussed Automation DSC and in this step, we will view a demo.

DSC Configuration Files

DSC configurations are PowerShell scripts that define a special type of function. Review this simple configuration.

A screenshot of a Powershell script, called LabConfig.ps1, demonstrating the configuration as code. The values assigned are Ensure as Present, Name as Web-Server, and IncludeAllSubFeature as True.

The Configuration block is the outermost script block. In this case, the name of the configuration is LabConfig. Notice the curly brackets to define the block

There can be one or more Node blocks. These define the nodes (computers and VMs) that you are configuring. In this example, the node targets a computer called WebServer.

Lastly, there can be one or more resource blocks. This is where the configuration sets the properties for the resources. In this case, there is one resource block called WindowsFeature. Notice the parameters that are defined.

Note: You can create the configuration in any editor, such as the PowerShell ISE. Save the file as a PowerShell script with a ps1 file type

Import and Compile

After you create your DSC configuration file, you must import the file and compile it to the DSC pull server. Compiling will create the MOF file.

A screenshot showing the import and compilation screens for the type of configurations shown in the previous image. In the first block, the import screen shows a box with ‘LabConfig.ps1’, a green tick, and a folder icon to demonstrate that it is an upload function. In the second block is the Compile screen for the now uploaded LabConfig configuration, asking whether the user is sure they wish to compile their DSC configuration. Clicking yes will add it to the Compilations jobs list

Note: If you prefer, you can use the PowerShell Start-AzureRmAutomationDscCompilationJob to compile the configuration file.

Registering DSC Nodes

After your configuration is in place, you select the Azure virtual machines or on-premises virtual machines that you would like to onboard:

A screenshot of the DSC Nodes page of Azure Resource Manager, showing the previously uploaded and compiled configurations deployed to virtual machines. The labels on-screen are Name, Status, and Node Configuration.

For each machine, you need to configure the registration data

A screenshot of the registration data configuration pop-up for new machines. The labels on the window are Registration key (a required field which can be set to either Primary or Secondary key), Node Configuration Name, Refresh Frequency, Configuration Mode Frequency, Configuration Mode, Allow Module Override, Reboot Node if Needed, and Action after Reboot.

Monitoring DSC Jobs

Each time that Azure Automation DSC performs a consistency check on a managed node, the node sends a status report back to the pull server. You can view these reports on the blade for that node.

A screenshot of the Nodes tab in Azure Resource Manager, where a specific node has been selected named MYVM0, allowing the user to view all the status reports run on the selected node. The labels are Type (in this case, showing Consistency), Status (saying Compliant), and Report Time which a full-length date and time result.

Notice that you can also Unregister the node and Assign it a different configuration.

In our next step, we will complete our second CloudSwyft Hands-On Lab focusing on standardising environments.

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