Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community
Azure & Desired State Configuration Part 1/4
Published Aug 16 2021 09:03 AM 5,456 Views


Part 1 : Focus on Desired State Configuration in PowerShell

Part 2 : Focus on Deploying with DevOps Pipeline

Part 3 : Focus on Azure Automation Account


I recently had a customer that requested some demo's on how they could use Azure Automation, Azure Devops and PowerShell Desired State Configuration to Automate their deployments and increase the quality of deployments. In this 4 Part Series I will be going through the different options you have for deploying Desired State Configuration and understanding that it is not some scary, vague concept that only developers can use. If you work in Operations(or any other area working with VMs and Operating Systems), this might be of great benefit ensuring consistent and repetitive deployments of what would have been admin intensive tasks previously. 

Part 1 : Deploy a Web Server on a new VM using Desired State Configuration in the Azure Portal

What will I need? 

- Visual Studio Code

- Azure Subscription (with Permissions to create resources)


  1. Create the Desired State Configuration PowerShell (.ps1) file that will be doing the Web Server Role Installation. If you would like to learn more about the structure of a DSC Script see DSC Configurations - PowerShell | Microsoft Docs 




  1. Compile the PowerShell file using the command shown below, your file will be saved as a “.zip” file. Compilation validates the configuration and allows for the input of parameter values. To learn more about compiling a configuration, see Compile DSC configurations in Azure Automation State Configuration | Microsoft Docs. 



  1. Upload this compressed “.zip” file to an Azure Storage Account



  1. Create a new Virtual Machine in the Azure Portal but stop at the Advanced Tab



  1. Click on Select an extension to install



  1. Scroll down and select PowerShell Desired State Configuration



  1. After following the prompts browse to your storage account and select your “.zip” file. Notice the “Module-qualified Name of Configuration” matches up with the module name we used in the PowerShell Script. Think of it as “ScriptName.ps1\ModuleName”



  1. Complete the Virtual Machine Creation



  1. Look at the Deployment and you will see the DSC extension running after creation



  1. Once the deployment is complete you can browse to Extensions in the VM Blade



  1. When logging in to the server you will see that IIS has been installed with all defaults






We just explored how easy it is to deploy a Web Server using our own Desired State Configuration file and the functionality of the Azure portal. There are many more items that can be installed, configured, and even repaired/auto corrected using Desired State Configuration. Some examples can be found: 

Official Documentation DSC Configurations - PowerShell | Microsoft Docs 

GitHub PowerShell/DscResources: Central repository for PowerShell Desired State Configuration (DSC) resourc... 

PowerShell Gallery PowerShell Gallery | Packages: 

Version history
Last update:
‎Aug 30 2021 02:29 AM
Updated by: