Tuesday 14 February 2017

PowerShell DSC Extension in Azure Resource Manager - PowerShell Method

Here are the steps I took to get the PowerShell DSC Extension for Azure Virtual Machines working using the PowerShell publishing method. In another post, I'll go through the JSON template method.

First, create an Azure VM using whichever method you prefer. I used the portal for simplicity. Most of my settings won't affect this, but for completeness, the settings I used for my VM are as follows:

Image: Windows Server 2016 Datacenter
Deployment Model: Resource Manager
Name: MyCoolVM
Disk Type: HDD
User name: Dave
Password: hunter2
Resource Group (New): DSC-Test-Resources
Location: North Europe
Size: A1 Basic
Settings Tab: All defaults except monitoring disabled.
Storage Account Name: dsctestresourcesdisks871

After creation, I opened the VM's network security group and added an inbound rule to allow port 80. I also added a DNS alias to the machine's public IP.

Once the VM is set up, open a text editor and create the following example DSC file:

In the same folder, make a deployment script as follows: 

The first command will publish the DSC configuration into a Zip file in your Azure storage account and return a predictable URL. The resulting blob will not be public.

Mine ended up here, but you can see the format which appears to use the normal blob URI and the powershell-dsc container:

A few seconds after the second command executes, you can see the new extension in your VM in the portal.

The status will move from (unavailable), to Transitioning, to Provisioning succeeded (or failed.)

If you click the extension you can get more details on the process, you can view the entire log from this blade.

And here is the finished web server:

Start to finish, including manual creation of the VM, this process took about 20 minutes.

If you use additional non-standard DSC resources, the PowerShell publish command will include the modules in the uploaded Zip file which is super handy.

Introduction to the Azure Desired State Configuration extension handler

No comments:

Post a Comment

Please be nice! :)

Nutanix CE 2.0 on ESXi AOS Upgrade Hangs

AOS Upgrade on ESXi from 6.5.2 to hangs. Issue I have tried to upgrade my Nutanix CE 2.0 based on ESXi to a newer AOS version for ...