Monday, June 15, 2015

Azure Resource Group Templates: Use Github quickstart template [Part 2]

 

[Part 1] : Azure Resource Group Templates: Infrastructure as a Code
[Part 2] : Azure Resource Group Templates: Use Github quickstart template (this Post!)

This tutorial is based on the Github quickstart templates: https://github.com/Azure/azure-quickstart-templates

Let choose a template to provision an AD, that looks easy, but when manually configured, it takes hours (and days if you have to re-do it you are missing a step)

image

Open the project, and click the “Deploy to Azure” button

image

This button calls the URL: https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Factive-directory-new-domain%2Fazuredeploy.json

It will open a new Browser in portal.azure.com and a blade will present the “Edit Template” mode (similar to Visual Studio in ‘Part 1’), where you could add for instance more VM Size (by default, only ‘Standard’ VP Type, i.e. too expensive for my needs).

image

You could add a ‘small’ entry (deprecated) if you wish PROVIDED YOU DO NOT NEED Loadbalancing, else if the template needs Loadbalancing, because the VM-Small does not support it, the deployment will crash.

(note the source code of the page is quite funny “Want to build awesome web applications like this one? Join us.”)

image  image

 

Within minutes, you will already have a complete configuration, while the remaining VM are provisionned (i.e. no green check yet).

image

Azure Resource Group Templates: Infrastructure as a Code [Part 1]

 

[Part 1] : Azure Resource Group Templates: Infrastructure as a Code (this Post!)
[Part 2] : Azure Resource Group Templates: Use Github quickstart template

Summary:

  • Part 1 uses the template that comes along with Powershell command lines. The chosen template is sharepoint that is used as a ground for orther variant configuration. You will be able to fully customize it and archive it as “Infrastructure As A Code”
  • Part 2 uses a template present in https://github.com/Azure/azure-quickstart-templates that has a button that redirects you to https://portal.azure.com with the template ‘instanciated’ for you. You just need to provide few parameters.

First get the latest version of Azure Powershell using Microsoft Web Platform Installer:

image
image

Note: for extra security, you have to sign in befor being able to use the various cmdLets of the Azure Service Management.
It will open a Web Browser Login page. The Powershell CmdLets to get this login is given in the error message below.
image

 

Get the Configuration Manager CommandLets

PS C:\> Switch-AzureMode -Name AzureServiceManagement
(source: https://msdn.microsoft.com/en-us/library/dn654592.aspx)

Then, among the 800 templates and over! pickup the one you are interrested in (to be handy for reading, I exported this list huge into a Word processing document). (source : https://msdn.microsoft.com/fr-fr/library/dn654596.aspx) 

image

Now pickup and download the template (or templates) that you are interrested in (type-in the exact same name). In our case, ‘Microsoft.SharePointFarm.0.2.31-preview’image

i.e.

PS C:\> Save-AzureResourceGroupGalleryTemplate -Identity Microsoft.SharePointFarm.0.2.31-preview c:\tmpVince

This will download a single *.JSON file.
Alternatively, you can get them from here : https://github.com/ciphertxt/AzureRM-SharePoint-Templates

 

In VS 2015 RC (at least), create a new project of type “Azure Reource Group”
image

Pick up any template you wish. Below is an example of “Web app + SQL” template.

image

To better understant the power of Azure Resource Manager, lets start with a blank template that will let you start with a minimum of files (i.e. not fully blank!)
image

Select the template JSON file, then in the outline window, click the “Add” icon. Add the ingredients you like (below Application Insights for Web Apps is illustrated for the sake of the example. Not needed in our Sharepoint example).
image image

 

For the Sharepoint server, just add our recently downloaded *.JSON files
image

The new VS2015 RC editor helps you visualize the various parameters and resources
image

Once happy with your configuration, as any VS project, in order to deploy, one would … right-click and “deploy”:
image

Then, fill in the parameters (either here or later VS will popup you windows), and hit ‘Deploy’ !

image => image

Wait for few minutes, and watch out for the Output Window.

If anything goes wrong, you will be notified, such as below:


01:26:38 - Build started.
01:26:38 - Project "Sharepoint.deployproj" (StageArtifacts target(s)):
01:26:38 - Project "Sharepoint.deployproj" (ContentFilesProjectOutputGroup target(s)):
01:26:38 - Done building project "Sharepoint.deployproj".
01:26:38 - Done building project "Sharepoint.deployproj".
01:26:38 - Build succeeded.
01:26:39 - The following parameter values will be used for this deployment:
01:26:39 -     newStorageAccountName: vizpocfullnestoacc
01:26:39 -     newDomainName: viseopoc.onmicrosoft.com
01:26:39 -     newVirtualNetworkName: viseopocfullvnet
01:26:39 -     vnetAddressSpace:
01:26:39 -     hostName: vizpochostn
01:26:39 -     userName: vincethavo
01:26:39 -     password: <securestring>
01:26:39 -     location: North Europe
01:26:39 -     hardwareSize: A1
01:26:39 - Launching deployment PowerShell script with the following command:
01:26:39 - 'c:\wks\azureresourcegrp\webandsql\Scripts\Deploy-AzureResourceGroup.ps1' -StorageAccountName '' -ResourceGroupName 'viseopoc-noeu-resourcegrp' -ResourceGroupLocation 'northeurope' -TemplateFile 'c:\wks\azureresourcegrp\webandsql\templates\microsoft.sharepointserver2013trial.0.2.80-preview.json' -TemplateParametersFile 'c:\wks\azureresourcegrp\webandsql\templates\microsoft.sharepointserver2013trial.0.2.80-preview.param.dev.json'
01:26:39 -
01:26:39 -
01:26:39 - Accounts            : {[viseopoc@outlook.com, Microsoft.Azure.Common.Authentication.Models.AzureAccount]}
01:26:39 - Subscriptions       : {[364f617a-9521-4356-9d3c-66751f255f41, Microsoft.Azure.Common.Authentication.Models.AzureSubscription]}
01:26:39 - DefaultSubscription : Microsoft.Azure.Common.Authentication.Models.AzureSubscription
01:26:39 - Environments        : {[AzureCloud, Microsoft.Azure.Common.Authentication.Models.AzureEnvironment], [AzureChinaCloud, Microsoft.Azure.Common.Authentication.Models.AzureEnvironment]}
01:26:39 - Context             : Microsoft.Azure.Common.Authentication.Models.AzureContext
01:26:39 - ProfileLoadErrors   :
01:26:39 - ProfilePath         :
01:26:39 -
01:26:39 - cmdlet New-AzureResourceGroup at command pipeline position 1
Supply values for the following parameters:
01:26:39 - locationFromTemplate: 01:26:46 - northeurope
01:26:54 - [VERBOSE] 1:26:54 AM - Created resource group 'viseopoc-noeu-resourcegrp' in location 'northeurope'
01:26:55 - [ERROR] New-AzureResourceGroup : Error 1: Code=InvalidDeployment; Message=The deployment parameter 'vnetAddressSpace' is not valid.
01:26:55 - [ERROR]
01:26:55 - [ERROR] At C:\wks\azureresourcegrp\webandsql\Scripts\Deploy-AzureResourceGroup.ps1:89 char:1
01:26:55 - [ERROR] + New-AzureResourceGroup -Name $ResourceGroupName `
01:26:55 - [ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
01:26:55 - [ERROR]     + CategoryInfo          : CloseError: (:) [New-AzureResourceGroup], ArgumentException
01:26:55 - [ERROR]     + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupCommand
01:26:55 - [ERROR] 
01:26:55 -
01:26:55 -
01:26:55 -
01:26:55 - Successfully deployed template 'c:\wks\azureresourcegrp\webandsql\templates\microsoft.sharepointserver2013trial.0.2.80-preview.json' to resource group 'viseopoc-noeu-resourcegrp'.


Once fixed, check that that the deployment was completed properly, by opening the Azure Resource Group ‘viseopoc-noeu-resourcegrp’

image

 

REFERENCES:

Open source Samples of templates https://github.com/Azure/azure-quickstart-templates
Azure Resource Management presentation https://mix.office.com/watch/1ssggs9jqdd72