DSC Pull Server in Azure

I was working on a DSC pull server v2 for the last couple of months. I heard about all the great new bells and whistles it brings and I was eager to test them. I was also working on a web interface such as Mark Gray showcased on PowerShell Summit Europe 2015 in Stockholm. Here is the video for his session: https://www.youtube.com/watch?v=y3-_XBQTpS8&index=33&list=PLfeA8kIs7CodimM6hjMqE13xHTPQUB8Pf

So I was working on an interface for pull server to upload DSC configs, assign them to servers and to monitor the deployment. then a couple of days back, I saw this video up on Channel 9, where they were talking about Azure automation, https://channel9.msdn.com/Blogs/Regular-IT-Guy/Automate-everywhere-with-the-new-Azure-Automation-in-OMS–with-special-guest-Jeffrey-Snover. Really a great video, except for that guy that keep on interrupting. 🙂 Just kidding Jeffrey 😉

There I saw that Azure now has DSC pull server option that can also manage on-prem servers. I just had to try it out!

So let’s open our Azure portal, https://portal.azure.com/ and then click through

  1. New Automation Account
  2. Dsc Configurations
  3. Add a configuration
  4. Compile configuration

You have to create a new automation account, then click on DSC Configurations Upload a configuration file and compile it. I created a simple test config, that just installs XPS Viewer. (Sorry for lack of indentation…it keeps disappearing :/)

XPSTest - Microsoft Azure
configuration XPSTest
{
node test
{
WindowsFeature XPS
{
Ensure = 'Present'
Name = 'XPS-Viewer'
}
}
}

Azure1

Now that we have config uploaded and compiled we have to apply it to a node.

If you want to manage Azure VMs.

  1. Make sure you user Virtual machines with new “Resource mode”
  2. Click on Automation Accout you just created
  3. Click on DSC Nodes
  4. Add Azure VM
  5. Select virtual machines to onboard
  6. Click OK
  7. Configure registration data
  8. Click OK
  9. And click Create

Azure3

There is one catch though. You can only manage “new” Azure VMs, created in Resource Mode, not “classic” VMs. Read here for explanation of differences: https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model/.

Azure2

If you want to configure on prem machine you can select Add on-prem VM in step 4. you will find some instructions on how to do that, but cmdlets you have there are out of date!

http://blogs.msdn.com/b/powershell/archive/2015/07/20/introducing-azure-resource-manager-cmdlets-for-azure-powershell-dsc-extension.aspx

https://github.com/Azure/azure-powershell/wiki/Deprecation-of-Switch-AzureMode-in-Azure-PowerShell

Azure4

These instructions are out of date!

So if you are like me and regularly update your modules, then you have to explore AzureRM module. Well. To be honest there is more than one.

https://www.powershellgallery.com/packages?q=azurerm

For onboarding on-prem VM to Azure DSC pull server, you will need AzureRM.Automation.

Login-AzureRmAccount
Get-AzureRmAutomationDscOnboardingMetaconfig -ResourceGroupName 'RG name' -AutomationAccountName 'Automation Acc Name' -ComputerName 'Computer Name' -OutputFolder 'Folder for MOF files'

Apply mof to server

Set-DscLocalConfigurationManager -Path .\DscMetaConfigs\ -ComputerName DSCJBK2-T

Now you can see both types of machines in your Azure automation account. You can also change which configuration they should pick up, and see the history, basically all I was about to do on my own, I just found out can be done in Azure. 🙂

Happy automating 🙂

 

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s