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.
Ensure your ARM Template, Parameters file and a new Yaml file is already uploaded into your DevOps Repo.
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
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
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.
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.
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.
If everything is configured correctly your build should be running now and it will look similar to below.
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”
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.
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.