Desired State Configuration with Azure Automation

Desired State Configuration (DSC) is a management platform in Windows PowerShell that helps ensure configuration consistency and compliance for on-premises and cloud-based environments. Azure Automation is a cloud-based platform for automating manual and repetitive IT processes. Together, DSC and Azure Automation can be used to manage and maintain the infrastructure at scale.

Here is a brief overview of how DSC can be used with Azure Automation:

  1. Configuration Scripts: DSC scripts are used to define the desired state of a system. These scripts specify the configuration settings, software, and other dependencies required for a system to function properly.
  2. Deployment to Azure Automation: Once the DSC scripts are created, they can be uploaded to Azure Automation. From there, they can be used to manage virtual machines, cloud-based systems, and on-premises servers.
  3. Continuous Compliance: With DSC and Azure Automation, organizations can ensure that their systems are always in a compliant state. If a system deviates from the desired state, DSC will automatically take action to bring it back into compliance.
  4. Scale Management: Azure Automation provides the ability to manage a large number of systems at scale, making it an ideal solution for organizations with complex IT environments. With DSC and Azure Automation, administrators can manage hundreds or even thousands of systems with ease.
  5. Reporting and Auditing: Azure Automation provides detailed reporting and auditing capabilities, allowing organizations to track changes and assess the health of their systems. This information can be used to identify potential problems and resolve issues quickly.
  6. Integration with other Azure Services: Azure Automation can be integrated with other Azure services, such as Azure Monitor and Log Analytics, providing a complete solution for infrastructure management and monitoring.

The following are the steps to enable DSC for your virtual machines on Azure.

  1. Create an Azure Automation Account as below and keep the defaults on Advanced, Networking, and Tags. Review and Create to complete the creation. You can refer to the link.
  2. Once the automation account is created, navigate to State Configuration (DSC) under Configuration Management and Click on Add to add the Virtual Machine to Configuration Management. Select the Virtual Machines from the list for which you want to manage the configuration.
  3. Click on Connect to add the machine as a node to State Configuration. It takes a few minutes to get the node listed in the nodes section
  4. Click on Configurations on State Configuration page and then click on Add to a Configuration. Before that, use the below code snippet as the configuration and save it as .ps1 file (PowerShell). In the script, we have mentioned that the SQL Service and IIS should always be Up and running.
  5. Now, browse the PowerShell file for the Configuration file. The Name should be the name of the configuration block in the PowerShell script. Once uploaded, you should see your configuration under the Configurations section. Now, select the configuration, and click on compile to produce the compiled configuration.
  6. Once it is compiled, you should see the same in the Compiled configuration section. You can also compile the PowerShell script locally to generate the compiled configuration file (MOF file) and upload it under Compiled configurations.
  7. Now, go to the nodes section and select the node to which the configuration should be applied. Click on Assign node configuration to use the configuration.
  8. Azure will run the configuration every 15 minutes and ensure that the services are running as mentioned in the configuration script. When the service is not running, Azure will mark it as non-Complaint and will try to bring the complaint. You can see the issues or errors during the configuration process in the history and on the nodes section of State Configuration as in Picture-1.

In conclusion, using DSC with Azure Automation can provide organizations with a powerful and flexible solution for managing infrastructure at scale. By ensuring configuration consistency and compliance, it helps to improve the reliability and security of IT systems.

Bhaskar Desharaju
Bhaskar Desharaju

He is an IT enthusiast, a blogger, and a DevOps practitioner. He works as Associate Architect in the DevOps/SRE space. He loves exploring new technologies and reading books and articles. In his leisure time, he spends time with family and friends.

Leave a comment

0 Shares
Share via
Copy link
Powered by Social Snap