What can we configure with PowerShell

Configuring computers with a desired status

The Azure Automation state configuration allows you to set configurations for your servers and ensure that these servers are in the specified state over time.

  • Integrate a virtual machine with Azure Automation DSC management
  • Upload a configuration to Azure Automation
  • Compiling a configuration into a node configuration
  • Assign a node configuration to a managed node
  • Check the compliance status of a managed node

For this tutorial we will use a simple DSC configuration that will ensure that IIS is installed on the VM.

requirements

Partial configuration support

Azure Automation State Configuration supports the use of partial configurations. In this scenario, DSC is configured to allow multiple configurations to be managed independently, with each configuration being pulled from Azure Automation. However, only one configuration can be assigned to a node using an automation account. This means that if you are using two configurations for one node, you will need two automation accounts.

For details on registering a sub-configuration from a pull service, see the sub-configuration documentation.

For more information about how teams can work together to co-manage servers using configuration as code, see Understanding DSC's Role in a CI / CD Pipeline.

Sign in to Azure

Sign in to your Azure subscription using the Connect-AzAccount cmdlet and follow the on-screen instructions.

Create and upload a configuration in Azure Automation

Type the following into a text editor and save the file locally as a TestConfig.ps1.

Note

In more complex scenarios where multiple modules need to be imported that provide DSC resources, you need to ensure that each module has a unique line of type in your configuration.

Call the Import-AzAutomationDscConfiguration cmdlet to upload the configuration to your Automation account.

Compiling a configuration into a node configuration

A DSC configuration must be compiled into a node configuration before it can be assigned to a node. See DSC Configurations for more information.

Call the Start-AzAutomationDscCompilationJob cmdlet to compile the configuration into a node configuration named in your Automation account.

Register a virtual machine for state configuration management

With Azure Automation State Configuration, you can manage Azure virtual machines (using the classic model or the Resource Manager model), local virtual machines, Linux machines, AWS virtual machines, and local physical machines. This topic covers registering only Azure Resource Manager VMs. For information about registering other types of computers, see Integrate computers for management by Azure Automation state configuration.

Call the Register-AzAutomationDscNode cmdlet to register your virtual machine as a managed node with the Azure Automation State Configuration.

Specify the configuration mode settings

Use the Register-AzAutomationDscNode cmdlet to register a virtual machine as a managed node and to specify configuration properties. You can e.g. For example, specify that the state of the computer should only be applied once by specifying the value of the property. State Configuration does not attempt to apply the configuration after the initial verification.

You can also specify how often DSC checks the configuration state by using the property. For more information about DSC configuration settings, see Configuring Local Configuration Manager.

Assign a node configuration to a managed node

Now we can assign the compiled node configuration to the VM to be configured.

This assigns the node configuration named to the registered DSC node. By default, the DSC node is checked for compliance with the node configuration every 30 minutes. To change the compliance check interval, see Configuring Local Configuration Manager.

Check the compliance status of a managed node

You can get reports on the compliance status of a managed node by using the Get-AzAutomationDscNodeReport cmdlet.

Next Steps