Desired State Configuration in Azure VM

Posted: October 11, 2017 in Azure

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

 

1

 

 

 

2.PNG

 

Now click All Resources-Automation Account

1.png

 

DSC configuration-Add Configuration

 

3.PNG

 

Upload deployment script and click compile (a mof file will be created in Azure automation DSC server)

 

4

Once job completed click on it

 

5.png

 

To see compilation details

 

6.PNG

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

 

1.png

Click DSC nodes-Add azure VM

 

8.png

 

 

9

Click Connect and from drop-down menu on right choose Configuration name (i need to install IIS so i chose WebaServer-click OK

 

10.png

After some minutes configuration should be deployed to Azure VM

 

12.PNG

 

Check it Out !

 

Log in to Azure VM, check logs

 

13

 

It seems IIS was indeed installed 🙂

 

14.PNG

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s