Azure Resource Manager

Page content

Microsoft is developing a whole new portal for Azure which has been in preview for a while now. You may have noticed that within this new portal everything is a resource. With the Azure Resource manager you can bundle different items like websites, databases and storage, or virtual networks and virtual machines. Currently there is no possibility to move already created items in Azure to a new resource to bundle them.

The basics

The resource manager gives you the possibility to manage sets of resources. At this moment, when you need a VM on Azure for your SharePoint development environment you need to create a Storage account and a VM. Then you need to install all the required software.

You need to start this whole process over when you need a new development environment. Alternative solutions like uploading VHD files and reusing a VHD using other tooling are available. But all of this takes a lot of time, every time you need a new development environment.

Now with the Azure Resource Manager you can define a template in JSON. In this template you can configure what you would like to have, like a storage account, one or more VM’s and a virtual network. With this template created, you can create your environment with a single click. Depending on the amount and type of resources this takes between a few minutes to several hours.

This sounds very easy but you still need to configure the machines you just created using the template. This can also be done with PowerShell Desire State Configuration, the Custom Script Extension for a VM of a combination of these 2. You still need to create those scripts.

The SharePoint template that is available on the new Azure Portal uses this. This template gives you four or nine VM’s with a Virtual Network, depending on the choices you make.

Although I have spoken here about VM’s, you can create everything that is available in the new portal with this resource manager.

Tooling

To create a resource, you need to create a JSON file that describes every bit of the resource you want to create. The easiest way to do this is using Visual Studio 2013 or the preview of 2015. With Visual Studio 2013 you can install an extension called “Azure Resource Manager Tools”

Figure 1: Azure Resource Manager Tools

With this extension you have a new project that you can create called “Cloud Deployment Project”. At the moment of writing this article, this project template has only three templates to choose from.

Figure 2: Cloud deployment Project

For now there are only templates for website with SQL and a Redis Cache. But as mentioned before you can also create other items. There are no Visual Studio templates for these yet. This should not be a problem, because you can download templates that are available within Azure to use as an example. How you can do this is well documented by Microsoft: http://azure.microsoft.com/en-us/documentation/articles/powershell-azure-resource-manager/. At this moment there are already over 5000 templates available to use within Azure. Of these templates there are only 1623 from Microsoft and 61 for SharePoint. There are that much templates because they create a new template for each new version.

Figure 3: Available SharePoint templates

Resource manager with Virtual machines

At the moment of writing this article we only have the templates for websites within Visual Studio. If you want to have templates to create virtual machines you need to be enrolled into the private preview. Within this preview you get new PowerShell scripts and updates to support the download of the more advanced Virtual machine templates. But the good news is that you can download the templates that are available from Azure. Not every template you download has content and that is because the advanced concepts are in draft and only available in the preview. But the templates you can download gives a lot of information how to create your own.

JSON template

The templates are all in JSON format. The template consists out of 4 parts; the schema, the content version, parameters and resources.

{ “$schema”: “http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", “contentVersion”: “1.0.0.0”, “parameters”: {}, “resources”: [] }

Listing 1: The 4 parts of the JSON template

The schema is a url which point to a specific schema that Visual Studio can use to provide IntelliSense. The content version is as far as I could find not used but for you own reference. The parameters are used in the Azure Portal or in PowerShell to personalize the settings in the template. And the resources contains all the resources that this template has to deploy.

If you use the template with PowerShell, PowerShell has access to the parameter part of the template. This will give you the same experience as any normal Cmdlet in PowerShell

New-AzureResourceGroup -Name TestRG ` -Location “East Asia” ` -GalleryTemplateIdentity Microsoft.WebSiteSQLDatabase.0.2.2-preview ` -siteName TestSite ` -hostingPlanName TestPlan ` -siteLocation “North Europe” ` -serverName testserver ` -serverLocation “West US” ` -administratorLogin Admin01 ` -databaseName TestDB ` -Verbose

Listing 2: PowerShell Cmdlet

In the resources part you specify every separate part of your solution. For a basic virtual machine you need at least 3 resources. A Storage account, a domain name and the virtual machine itself. Each of these resources has their own properties you need to provide.

Conclusion

The Azure Resource Manager is a great way to create repeatable environments. Not only for virtual machines to host your SharePoint development, test or acceptance environment. It can also be used to create websites or any other resource or set of resources that you repeatable need to create. It is a new feature of the ever involving Azure platform with a lot of potential.

This article is also in the DIWUG Magazine 15