Monday, September 6, 2021

Azure & Desired State Configuration Part 4/4

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

Part 4 : Focus on DSC in Automation Account

Scenario

Until now we have seen web servers deployed on new VM’s, how to create DSC Scripts, how to tie this into DevOps and even some cool features of Azure Automation Account. In this final article we will see a great feature that could simplify some our scenarios.

Part 4: Azure Automation DSC

 

What will I need? 

- Azure Subscription (with Permissions to create resources)

- Automation Account

 Steps

  1. On to the State Configuration section of Azure Automation Account. First of all it is located under the Configuration Management Section of our Azure Automation Account.

wernerrall_0-1628084204317.png

 

  1. As we can see there is already two nodes (Servers) added and I can add more by clicking the “+ Add” button. Note this is to add the device so it can be managed by the Automation Account State Configuration. No DSC configuration is being deployed yet. I also have options like Refresh Frequency (How often to check in if the DSC scripts have updated) and Configuration Mode Frequency(How often the server should check its own compliance by running DSC Script it already has). We also have some Configuration Mode options like ApplyAndMonitor(Once Off Configuration) or ApplyAndAutoCorrect(Configure and fix every time)

wernerrall_1-1628084204353.png

 

  1. The next step after adding a Node is to add a Configuration. What makes this step easier than writing your own DSC file and compiling it (Part 1) is the Automation Account will do the compilation for you and store this script. No need for Azure Storage account. So it saves you from some complexity.

wernerrall_2-1628084204437.png

 

  1. I even have the option to go to the gallery and get some new DSC Templates for my nodes.

wernerrall_3-1628084204506.png

 

  1. For the purposes of this article, we will use our “iis_setup.ps1” file from Part 1 of this series. We can browse and import our DSC file.

wernerrall_4-1628084204532.png

 

  1. Once the file has been imported we can click on it.

wernerrall_5-1628084204581.png

 

  1. I still need to compile this file (Which we would have had to do with a PowerShell command if we weren’t using Azure Automation Account). Compilation validates the configuration and allows for the input of parameter values.

wernerrall_6-1628084204607.png

 

  1. Upon the completion of the compilation, I can add this configuration to one of my nodes.

wernerrall_7-1628084204662.png

 

  1. Now that everything is configured, let remove the IIS Role from our Web Server and see what happens

wernerrall_8-1628084204690.png

 

wernerrall_9-1628084204716.png

 

wernerrall_10-1628084204718.png

 

  1. Upon my login after the removal and restart I go to the browser and to my surprise, IIS is still showing up. What happened here?

wernerrall_11-1628084204748.png

 

  1. Technically it shouldn’t be a surprise because I told the DSC configuration always keep Web Server installed. Clicking on the node I can see it shows compliant

wernerrall_12-1628084204795.png

 

  1. I can also see upon my restart it took about 2 minutes and 7 seconds to “Correct” my uninstall. Wow, that is neat!

wernerrall_13-1628084204852.png

 

Video

 

 

Conclusion

Thank you for following this 4 Part Series on Azure & Desired State Configuration. I hope the items mentioned in here has been beneficial to you and will assist you in your Automation Journey. Keep trying, keep learning and stay positive.

 

“Automation may be a good thing, but don’t forget that it began with Frankenstein.” – Anonymous

 

Posted at https://sl.advdat.com/3zJRriu