Azure & Desired State Configuration Part 2/4
Published Aug 23 2021 07:58 AM 3,631 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

 

In Part 1 Azure & Desired State Configuration Part 1/4 - Microsoft Tech Community we saw how we could deploy a web server on a new VM in using a Desired State Configuration file and the Azure Portal. Now we will take this a step further and set up the deployment in a Pipeline on Azure Devops. This will be most likely one the ways you could Automate deployments in your organization and increase collaboration. Completing the below requires knowledge on Azure DevOps in relation to Repo’s and Pipelines. If you are not yet familiar with these please have a look at our learning modules below. Respectfully the focus of this Article is to showcase DSC in DevOps not to explain the entire process.

  1. AZ-400: Manage source control - Learn | Microsoft Docs
  2. AZ-400: Define and implement continuous integration - Learn | Microsoft Docs

 

Part 2: Deploy a Web Server using DevOps

What will I need? 

- Azure Subscription (with Permissions to create resources)

- The Storage Account and DSC Script from Part 1 of this series

- Azure DevOps Organization Service Connection set up to communicate with Azure (Service connections in Azure Pipelines - Azure Pipelines | Microsoft Docs)

- If DevOps Organization has been running in Free Tier you need to request compute by filling in this form (https://aka.ms/azpipelines-parallelism-request more information at Change in Azure Pipelines Grant for Private Projects | Azure DevOps Blog (microsoft.com) )

- ARM template for deploying Virtual Machine (Can be found in Azure QuickStart templates on GitHub - azure-quickstart-templates/101-simple-windows-vm at master · github/azure-quickstart-templates)

 Steps

  1. Ensure your ARM Template, Parameters file and a new Yaml file is already uploaded into your DevOps Repo.

wernerrall_0-1628078667380.png

 

  1. Under the Resources section of your ARM Template you are going to want to add the following section in. This will allow Azure Resource Manager to understand you want to add an extension of the type Microsoft.Powershell.DSC to the Virtual Machine

wernerrall_1-1628078667428.png

 

  1. When authoring this section you want to also take note of the “dependsOn” property. Without this, the deployment may fail because it does not wait for your VM to be deployed before trying to execute the extension install

 

wernerrall_2-1628078667470.png

 

  1. Another important section is where I specified default values for the Storage Account and DSC Script file in the ARM Template under “Parameters” section. This can also be specified in your parameters.json file associated with deployment file.

wernerrall_3-1628078667493.png

 

  1. Below is an example of what your Yaml file should look like. For now I am not adding any triggers or automatic build actions. This can be set by modifying Line 3 and Line 5.

wernerrall_4-1628078667525.png

 

  1. Let’s kick off the manual build. This is accomplished by going to Pipelines, selecting your Pipeline and clicking Run Pipeline. If you do not see a pipeline here you can create a pipeline using your Yaml file.

wernerrall_5-1628078667548.png

 

  1. If everything is configured correctly your build should be running now and it will look similar to below.

wernerrall_6-1628078667586.png

 

  1. We can also go to the Azure Portal and see if my deployment is running. This is done by clicking on the resource group you targeted and then clicking on “Deployments” under “Settings”

wernerrall_7-1628078667620.png

 

  1. Upon completion of the deployment I can navigate to the server and if I log into the server I will see that the DSC ran successfully and I will have IIS installed.

wernerrall_8-1628078667646.png

 

wernerrall_9-1628078667673.png

 

 

Video

 

 

Conclusion

In this article we saw how it is possible to create a pipeline in DevOps to deploy an Arm Template that contains a DSC Extension. This means not only can I deploy infrastructure but I can customize the roles and features they deploy with. Stay Tuned for Part 3 where we will be exploring our next step in Automation tooling, Azure Automation Account.

 

Co-Authors
Version history
Last update:
‎Aug 31 2021 12:07 AM
Updated by: