title: Getting started with Azure Automation DSC | Microsoft Docs description: Explanation and examples of the most common tasks in Azure Automation Desired State Configuration (DSC) services: automation documentationcenter: na author: eslesar manager: carmonm editor: tysonn
ms.assetid: a3816593-70a3-403b-9a43-d5555fd2cee2 ms.service: automation ms.devlang: na ms.topic: article ms.tgt_pltfrm: powershell ms.workload: na ms.date: 11/21/2016 ms.author: magoedte;eslesar
This topic explains how to do the most common tasks with Azure Automation Desired State Configuration (DSC), such as creating, importing, and compiling configurations, onboarding machines to manage, and viewing reports. For an overview of what Azure Automation DSC is, see Azure Automation DSC Overview. For DSC documentation, see Windows PowerShell Desired State Configuration Overview.
This topic provides a step-by-step guide to using Azure Automation DSC. If you want a sample environment that is already set up without following the steps described in this topic, you can use the following ARM template. This template sets up a completed Azure Automation DSC environment, including an Azure VM that is managed by Azure Automation DSC.
To complete the examples in this topic, the following are required:
- An Azure Automation account. For instructions on creating an Azure Automation Run As account, see Azure Run As Account.
- An Azure Resource Manager VM (not Classic) running Windows Server 2008 R2 or later. For instructions on creating a VM, see Create your first Windows virtual machine in the Azure portal
We will create a simple DSC configuration that ensures either the presence or absence of the Web-Server Windows Feature (IIS), depending on how you assign nodes.
-
Start the Windows PowerShell ISE (or any text editor).
-
Type the following text:
configuration TestConfig { Node WebServer { WindowsFeature IIS { Ensure = 'Present' Name = 'Web-Server' IncludeAllSubFeature = $true } } Node NotWebServer { WindowsFeature IIS { Ensure = 'Absent' Name = 'Web-Server' } } }
-
Save the file as
TestConfig.ps1
.
This configuration calls one resource in each node block, the WindowsFeature resource, that ensures either the presence or absence of the Web-Server feature.
Next, we'll import the configuration into the Automation account.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Configurations.
-
On the DSC Configurations blade, click Add a configuration.
-
On the Import Configuration blade, browse to the
TestConfig.ps1
file on your computer. -
Click OK.
After you have imported a configuration, you can view it in the Azure portal.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Configurations
-
On the DSC Configurations blade, click TestConfig (this is the name of the configuration you imported in the previous procedure).
-
On the TestConfig Configuration blade, click View configuration source.
A TestConfig Configuration source blade opens, displaying the PowerShell code for the configuration.
Before you can apply a desired state to a node, a DSC configuration defining that state must be compiled into one or more node configurations (MOF document), and placed on the Automation DSC Pull Server. For a more detailed description of compiling configurations in Azure Automation DSC, see Compiling configurations in Azure Automation DSC. For more information about compiling configurations, see DSC Configurations.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Configurations
-
On the DSC Configurations blade, click TestConfig (the name of the previously imported configuration).
-
On the TestConfig Configuration blade, click Compile, and then click Yes. This starts a compilation job.
Note
When you compile a configuration in Azure Automation, it automatically deploys any created node configuration MOFs to the pull server.
After you start a compilation, you can view it in the Compilation jobs tile in the Configuration blade. The Compilation jobs tile shows currently running, completed, and failed jobs. When you open a compilation job blade, it shows information about that job including any errors or warnings encountered, input parameters used in the configuration, and compilation logs.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Configurations.
-
On the DSC Configurations blade, click TestConfig (the name of the previously imported configuration).
-
On the Compilation jobs tile of the TestConfig Configuration blade, click on any of the jobs listed. A Compilation Job blade opens, labeled with the date that the compilation job was started.
-
Click on any tile in the Compilation Job blade to see further details about the job.
Successful completion of a compilation job creates one or more new node configurations. A node configuration is a MOF document that is deployed to the pull server and ready to be pulled and applied by one or more nodes. You can view the node configurations in your Automation account in the DSC Node Configurations blade. A node configuration has a name with the form ConfigurationName.NodeName.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Node Configurations.
You can use Azure Automation DSC to manage Azure VMs (both Classic and Resource Manager), on-premises VMs, Linux machines, AWS VMs, and on-premises physical machines. In this topic, we cover how to onboard only Azure Resource Manager VMs. For information about onboarding other types of machines, see Onboarding machines for management by Azure Automation DSC.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Nodes.
-
In the DSC Nodes blade, click Add Azure VM.
-
In the Add Azure VMs blade, click Select virtual machines to onboard.
-
In the Select VMs blade, select the VM you want to onboard, and click OK.
[!IMPORTANT] This must be an Azure Resource Manager VM running Windows Server 2008 R2 or later.
-
In the Add Azure VMs blade, click Configure registration data.
-
In the Registration blade, enter the name of the node configuration you want to apply to the VM in the Node Configuration Name box. This must exactly match the name of a node configuration in the Automation account. Providing a name at this point is optional. You can change the assigned node configuration after onboarding the node. Check Reboot Node if Needed, and then click OK.
The node configuration you specified will be applied to the VM at intervals specified by the Configuration Mode Frequency, and the VM will check for updates to the node configuration at intervals specified by the Refresh Frequency. For more information about how these values are used, see Configuring the Local Configuration Manager.
-
In the Add Azure VMs blade, click Create.
Azure will start the process of onboarding the VM. When it is complete, the VM will show up in the DSC Nodes blade in the Automation account.
You can view the list of all machines that have been onboarded for management in your Automation account in the DSC Nodes blade.
- Sign in to the Azure portal.
- On the Hub menu, click All resources and then the name of your Automation account.
- On the Automation account blade, click DSC Nodes.
Each time 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.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Nodes.
-
On the Reports tile, click on any of the reports in the list.
On the blade for an individual report, you can see the following status information for the corresponding consistency check:
- The report status — whether the node is "Compliant", the configuration "Failed", or the node is "Not Compliant" (when the node is in applyandmonitor mode and the machine is not in the desired state).
- The start time for the consistency check.
- The total runtime for the consistency check.
- The type of consistency check.
- Any errors, including the error code and error message.
- Any DSC resources used in the configuration, and the state of each resource (whether the node is in the desired state for that resource) — you can click on each resource to get more detailed information for that resource.
- The name, IP address, and configuration mode of the node.
You can also click View raw report to see the actual data that the node sends to the server. For more information about using that data, see Using a DSC report server.
It can take some time after a node is onboarded before the first report is available. You might need to wait up to 30 minutes for the first report after you onboard a node.
You can assign a node to use a different node configuration than the one you initially assigned.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Nodes.
-
On the DSC Nodes blade, click on the name of the node you want to reassign.
-
On the blade for that node, click Assign node.
-
On the Assign Node Configuration blade, select the node configuration to which you want to assign the node, and then click OK.
If you no longer want a node to be managed by Azure Automation DSC, you can unregister it.
-
Sign in to the Azure portal.
-
On the Hub menu, click All resources and then the name of your Automation account.
-
On the Automation account blade, click DSC Nodes.
-
On the DSC Nodes blade, click on the name of the node you want to unregister.
-
On the blade for that node, click Unregister.