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,526 Views
Microsoft

Index

Part 1 : Focus on Desired State Configuration in PowerShell

Part 2 : Focus on Deploying with DevOps Pipeline

Part 3 : Focus on Azure Automation Account

Scenario

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)

 Steps

  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 

 

wernerrall_0-1628070359608.png

 

  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. 

wernerrall_1-1628070359619.png

 

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

wernerrall_2-1628070359645.png

 

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

wernerrall_3-1628070359667.png

 

  1. Click on Select an extension to install

wernerrall_4-1628070359684.png

 

  1. Scroll down and select PowerShell Desired State Configuration

wernerrall_5-1628070359707.png

 

  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”

wernerrall_6-1628070359723.png

 

  1. Complete the Virtual Machine Creation

wernerrall_7-1628070359746.png

 

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

wernerrall_8-1628070359780.png

 

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

wernerrall_9-1628070359793.png

 

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

wernerrall_10-1628070359822.png

 

Video

 

Conclusion

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: 

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