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)
- 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
- 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.
- Upload this compressed “.zip” file to an Azure Storage Account
- Create a new Virtual Machine in the Azure Portal but stop at the Advanced Tab
- Click on Select an extension to install
- Scroll down and select PowerShell Desired State Configuration
- 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.ps1ModuleName”
- Complete the Virtual Machine Creation
- Look at the Deployment and you will see the DSC extension running after creation
- Once the deployment is complete you can browse to Extensions in the VM Blade
- 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
PowerShell Gallery PowerShell Gallery | Packages: