A feature request for quite some time in the Microsoft Azure space has been the ability to group individual resources such as websites and databases so that they can be grouped and managed as part of a single solution or system. In this post we’ll take a look at what has been introduced so far through 2014 to meet these needs.

Say Hello to Azure Resource Manager

The first piece of the solution to these requests was the introduction of the Azure Resource Manager (ARM) way back at Build 2014 along with the new Azure Preview Portal which offers support for Resource Groups. Since then work has been progressively undertaken to deliver both PowerShell and Cross-Platform CLI capabilities to support Resource Manager.

A little confusingly perhaps, the ability to utilise Azure Resource Manager requires you to switch the “mode” of your preferred management platform from the standard management mode to one that supports ARM. If you start either PowerShell or the Xplat CLI you will need to change mode as shown below.

[code language=”powershell”]
# PowerShell
Switch-AzureMode -Name AzureResourceManager
[/code]

[code language=”javascript”]
// XPlat CLI
azure config mode arm
[/code]

Note that the traditional publish settings file won’t cut it for authentication with this setup. You will need to create a new setting by following the appropriate instructions which can be found on the Azure Resource Manager page on the Azure Documentation site.

Now that we’re in the right operational mode what can we do? Well we can either publish our own templates or use one of a number of pre-built templates to deploy a range of services. Right now the choice is fairly limited but it will grow over time as the number of ARM-supported Azure service grows. We’ll take a look at more in a moment.

Not So Scripty!

As I mentioned above, along with Azure Resource Manager at Build there was also the release of the new Azure Preview Portal as shown below. This bakes Resource Manager support in in the most subtle of ways – the region highlighted with the bright blue box takes you to the Resource Gallery where there are lots of prepared templates for you to use.

New Azure Portal

Great! So we can see how we tie all this Resource Manager stuff together. Now for the final piece – Tags.

Tagging Things

Starting early October 2014 we now have native capability to add Tags to Resources and Resource Groups using the both Powershell Cmdlets and the Cross-Platform CLI.

Tags are simply a collection of basic key value pairs in the form “key=value”. This design affords a great deal of flexibility in what you can assign to Tags.

Let’s take a look at how we add a set of Tags when we create a new Resource Group based on an existing template. Note these two code samples are mostly complete but not fully functional – they are really designed just to show how you declare Tags.

[code language=”powershell”]
# Build up Tags to apply
$myTags = New-Object System.Collections.ArrayList;
$myTags.Add(@{ Name="owner"; Value="simon"})
$myTags.Add(@{ Name="env"; Value="demo"})

# Create new resource and supply Tags array
New-AzureResourceGroup -Tags $myTags -Name SimonRGDemo `
-Location "West US" `
-GalleryTemplateIdentity Microsoft.WebSiteSQLDatabase.0.2.1-preview `
-siteName DemoSite -sku Free -hostingPlan SimonPlan `
-serverName "SimonDBDemo" -serverLocation "West US" `
-siteLocation "West US" -administratorLogin simonw `
-databaseName simonDB -Verbose
[/code]

[code language=”javascript”]
// XPlat CLI
azure group create -t owner=simon;env=demo -n "SimonDemo2" -l "West US" -d SimonDeployment -y Microsoft.WebSiteSQLDatabase.0.2.1-preview -e setup.json
[/code]

We run this script and when it has completed we can hop into the new Azure Portal and view the blade for the Resource Group and see two Tags defined as shown below.

Azure Resource Group with Tags

Now that we have started tagging resources we can begin to manage and filter our resources through this mechanism too. It’s still early days for Tags in Azure so I expect we’ll see much deeper support in the longer term.

Here’s a good tip for you too – if you find you’re stuck because the online Azure documentation is behind the official tooling release you can always take a look on the Azure team’s Github site to see what they’ve built. Granted it’s not easy to follow but it will give you good hints on how things should work (like Tags on the Xplat CLI which can be found defined here: https://github.com/Azure/azure-sdk-tools-xplat/blob/master/lib/commands/arm/group/group._js).

HTH.

Category:
Azure Infrastructure, Azure Platform
Tags:
,

Comments are closed.