Microsoft Azure Automation Using PowerShell Desired State Configuration And Node Configuration And Management

Microsoft Azure is very aggressivly providing Automation Solutions and Services to users by Azure Automation Service, by which we can automate the manual, long-running and frequent periodically-repeating tasks of the cloud and can manage and configure a number of nodes. It will definitely save the users and developers time.  User scan regularly administer all tasks in Azure and also schedule all tasks using so many options that are available in Azure.

Microsoft Azure provides you two ways to perform Automation,

  • Runbook
  • Desired State Configuration

In this article, we are talking about Desired State Configuration Scripts using PowerShell. Desired State Configuration is an easy management platform in PowerShell which enables you to manage your IT/Development infrastructure with configuration as coding. DSC is basically a declarative script which is used to configure, Deploy and Manage Systems, which has basically three primary components: 1. Configurations – It is a declarative PowerShell script which defines and configures instance of resources. i.e. Web Server IIS 2. Resources – It contains code that you want to put in and keeps the target of a configuration in the specified state of VM. 3. Local Configuration Manager – It is an engine which facilitates the interaction between resources and configurations and it checks the state. If the system is out of state it's called to the code in resources according to configurations.

Microsoft Azure Automation Desired State Configuration and Node Management is about how to do the most common tasks like creating, importing and compiling configurations and onboarding VMs to manage and view the reports. In this article let us create one PowerShell DSC script and configure VM using Microsoft Azure Automation Service DSC Configuration. First open Notepad file and add script of IIS Installation (Web Server) and save as that file as webserver.ps1

Microsoft Azure Automation

After this open portal.azure.com login with your active azure account and create new Automation Service Click New – Search Automation and create service.

Microsoft Azure Automation

Now we are going to automate our Windows Server 2012 R2 Datacenter Operating system Virtual Machine and we are going to configure the webserver using PowerShell DSC by Azure Automation Service. For that please create Windows 2012 R2 DC Operating System VM in Azure Portal and Download RDP file to remotely access it. After that in Azure Automation Service Menu Click on DSC Configuration Option.

Microsoft Azure Automation

After clicking on Add a Configuration button a new form will open to browse your webserver.ps1 PowerShell script which is available in our local machine, Browse it and you can also add a description of that PowerShell script and click OK.

Microsoft Azure Automation

After that step, click on Configuration file which we recently uploaded and click on compile button to compile it

Microsoft Azure Automation

After compilation status looks completed that means there is no error in your PowerShell DSC Script, and you can now configure Node and apply this PowerShell DSC script configuration on VM which we recently created of Windows 2012 OS. For that we need to click on DSC Nodes option in Automation Service Menu and there are two options available. Add Azure VM or Add on premise VM.

Microsoft Azure Automation

In our case we need to add Azure VM and select our Virtual Machine, suketuvm, which we created for this example of Windows 2012 OS.

Microsoft Azure Automation

After that selection of your VM, in my case it is Suketuvm, which I selected and click on Registration Tab. It looks like  the above snap; click on that and select your node configuration file name of PowerShell script in dropdown box as shown in the below snap. Then Check Box Reboot if Needed and Click OK.

Microsoft Azure Automation

After selection of node configuration file and clicking on Reboot Node if needed click ok and then click on Create button of previous Tab. Then deployment has started and you can see that in Notification Tab.  It will take a few minutes for the configuration and automatically VM name will come in portal with status compliant as shown in the below snap.

Microsoft Azure Automation

After this please login to your VM using RDP file open C Drive Inetpub folder and inside inetpub you will find wwwroot folder that means PowerShell DSC has configured successfully and IIS Web Server installation has succeeded. So, like this you can manage and configure multiple nodes and use multiple DSC scripts in Azure Automation service.


Similar Articles