This is the part 2 of the Azure Automation DSC blog series. Last post I gave a brief introduction to what is Azure Automation and methods how we can achieve DSC. This post I’ll walk-through how to onboarding a Windows Server Node (Azure VM ) to Azure Automation DSC.
Before We Start
- Need to have a Azure Subscription.
- Permission to create and modify Azure Automation Account.
- Permission to manage Azure VM.
First Create a Azure Automation Account if you haven’t create yet
Click Add to create new account
Give a account name, resource group & location then click create
Now we create a automation account next we need the DSC configurations, we can add DSC configuration scripts to automation account.
Following is the sample DSC code I used for this demo
Configuration FileResourceDemo { Node 'localhost' { File CreateFile { DestinationPath = 'c:\text.txt' Ensure = 'Present' Contents = "Hello World !!!!" } } }
Above code ensure that there is a file named and text.txt and it contains “Hello World !!!!”. So when we apply this DSC configuration to a node Azure Automation account constantly check whether the Node is complaint with above configuration. If the Node has any changes it revert back to the configuration as DSC script.
Now we added the DSC configuration and it shows as bellow.
Now Lets on-board a VM.
Next configure the registration data. In this pane we select which DSC configuration should apply to this VM.
After click ok it start to install the PowerShell DSC extension to VM. We can see the extension as below
In VM We can see the extension installed
So lets verify the configurations we mentioned in the script are applied to the VM. I login to the VM and open the file explore then I can see the text file I mentioned in the DSC created.
LCM (Local Configuration Manager ) periodically check the desired state of the configurations are complied and if its not complaint it get the configuration from the Automation account and apply it.