Azure & Desired State Configuration Part 1/4

Scenario

I recently had a customer that requested some demo's on how they could use Azure Automation, Azure and PowerShell 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 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? 

Code

– Azure Subscription (with Permissions to create resources)

 Steps

  1. >Create the PowerShell (.ps1) file that will be doing the Web Server Role Installation. If you would like to learn more about the structure of aDSC ScriptseeDSC 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,seeCompile DSC configurations in Azure Automation State Configuration | Microsoft Docs>. 

wernerrall_1-1628070359619.png

  1. Upload this compressed “.zip” file to an Azure 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 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.ps1ModuleName”

wernerrall_6-1628070359723.png

  1. Complete the 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 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) resources. (github.com) 

PowerShell Gallery PowerShell Gallery | Packages: 

 

This article was originally published by Microsoft's Azure Blog. You can find the original article here.