Desired State Configurations (DSC) are PowerShell scripts that we can use to remotely configure Windows servers,for example we can deploy server roles to multiple server without need to directly manage them.
In this example we’ll deploy IIS to Azure VM using DSC
Deployment script (save it with ps1 extension):
configuration TestConfig { Node WebaServer { WindowsFeature IIS { Ensure = 'Present' Name = 'Web-Server' IncludeAllSubFeature = $true } } Node NotWebServer { WindowsFeature IIS { Ensure = 'Absent' Name = 'Web-Server' } } }
I needed to name node as WebaServer, otherwise it won’t work (in fact we need to add any character between Web and Server-bug maybe ?)
Creating automation account
We need account under which DSC will run.In Azure portal click new-type automation
Now click All Resources-Automation Account
DSC configuration-Add Configuration
Upload deployment script and click compile (a mof file will be created in Azure automation DSC server)
Once job completed click on it
To see compilation details
Under automation account properties click DSC node configuration to see available configurations,in this example we have one which will install IIS and one which will remove it if it’s installed, my VM has no IIS so i’ll assign first configuration
Click DSC nodes-Add azure VM
Click Connect and from drop-down menu on right choose Configuration name (i need to install IIS so i chose WebaServer-click OK
After some minutes configuration should be deployed to Azure VM
Check it Out !
Log in to Azure VM, check logs
It seems IIS was indeed installed 🙂