You are on page 1of 4

AzureCon Challenge

Deploying Services using ARM Templates


Overview
In this challenge you will learn the very basics of using Azure Resource Manager (ARM) Templates to deploy services on Azure. ARM Templating allows you
to automate the deployment process enabling you to became more agile and deploy new environments much quicker.
In this challenge you will deploy Service Plans, Web Applications, SQL Servers, and SQL Databases.

1. Login to Azure
For this challenge, you have either elected to use your own subscription or have created a new Azure
subscription using the provided Azure Pass (or Free Trial). If you want to switch to use the provided Azure
Pass the promotion code is displayed on the My Account page on the http://challenge.azurecon.com web
site. If there is no promo code displayed, you will need to use the free trial http://azure.microsoft.com/pricing/free-trial.
Azure has TWO management portals - the classic portal (http://manage.windowsazure.com) and a new
portal that is in Preview at http://portal.azure.com. You will use the Preview portal in this challenge.
1.

Open a browser and go to http://portal.azure.com

2.

Enter your Microsoft Account email address and password for the Microsoft Account you
associated with your Azure Pass or your own subscription.

3.

You will now be in your Azure subscription (see opposite) and from here you can create and
manage Azure services.

2. Create a single App Service Plan (Hosting Plan)


In this task we are going to create a deployment using an ARM Template to deploy a single App Service Plan.
1.

In the portal press + New -> Marketplace.

2.

In the search box at the top, type Template Deployment and press enter

3.

Click the template deployment item and click Create.

4.

Click Edit Template.


A template is a description of all the resources
that you want to deploy. When you deploy
resources, most of the time you also need to
supply parameters for example the region a
resource needs to be deployed. Templates can
also describe dependencies between resources
do this, but do it after that, for example.
When you deploy services themselves in Azure,
for example a Virtual Machine or a Web App
a template is used under the covers to describe
the service and an Azure service called the
Azure Resource Manager is used to execute the
templates instructions.

5.

On the Edit template window locate the line containing his code: "parameters": {}. This should be line 4. Between the { } put the following code:
"hostingPlanName": {

Page | 1

"type": "string",
"metadata": {
"description": "The name of the App Service plan
}
},
"siteLocation": {
"type": "string",
"metadata": {
"description": "The location to use for creating
}
},
"sku": {
"type": "string",
"allowedValues": [
"Free",
"Shared",
"Basic",
"Standard"
],
"defaultValue": "Free",
"metadata": {
"description": "The pricing tier for the hosting
}
},
"workerSize": {
"type": "string",
"allowedValues": [
"0",
"1",
"2"
],
"defaultValue": "0",
"metadata": {
"description": "The instance size of the hosting
}
}

to use for hosting the web app."

the web app and hosting plan."

plan."

plan (small, medium, or large)."

This code defines the parameters that will be used for the template.
6.

On the Edit template window locate the line containing his code: "resources": [ ]. This should be around line 43. Between the [ ] put the following
code:
{
"apiVersion": "2015-04-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverFarms",
"location": "[parameters('siteLocation')]",
"properties": {
"name": "[parameters('hostingPlanName')]",
"sku": "[parameters('sku')]",
"workerSize": "[parameters('workerSize')]",
"numberOfWorkers": 1
}
}

This code defines the services that need to be created, in this case an Application Plan.
7.

In order to make your life easier for the next tasks, copy the whole configuration. Open Notepad and paste the configuration there.

8.

Go back to the portal and press Save.

9.

On the Resource Group blade press the Or create new link, and choose
templateRG as the name of your Resource Group.

10.

Click on Resource Group Location and select any of the available regions.

11.

Click the Edit parameters link.

12.

For the Hosting Plan Name, use templateASP.

13. For the Site Location use the SAME value you selected for the Resource
Group Location which is displayed in the Resource Group Location link (Japan
East in the example opposite).
14. Leave the other values alone and press OK
15.

Click on Legal Terms and press Buy, to indicate that you agree with the Legal
Terms (there is no purchase involved, but some resources cost money, so that
is why Microsoft chose this word).

16.

Make sure that Pin to Startboard is selected, and the press the Create
button.

Page | 2

17.

After less than a minute, your App Service Plan is created and a blade with your resource group will be open.

3. Create a single App Service Plan and a Web App


In this task we are going to create a template that generates an App Service Plan and a Web Application that will use the service plan in the exiting resource
group.
1.

You are going to repeat creating the template you did in the previous task, but you have all this
copied in Notepad ready to go.

2.

Create a new template (+New -> Marketplace Search for Template Deployment and create a
template.

3.

Click on Edit Template and delete everything that is there.

4.

Switch to Notepad where you old template definition is waiting.

5.

In the parameters section you need to add the following parameter at the beginning of the list
so right after the opening {
"siteName": {
"type": "string",
"metadata": {
"description": "The name of the web app that you wish to create."
}
},

6.

In the resources section add a comma after the existing resource, so directly BEFORE the last ] closing square bracket and then add the
following resource:
{
"apiVersion": "2015-06-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/Sites",
"location": "[parameters('siteLocation')]",
"dependsOn": [
"[concat('Microsoft.Web/serverFarms/', parameters('hostingPlanName'))]"
],
"properties": {
"name": "[parameters('siteName')]",
"serverFarmId": "[parameters('hostingPlanName')]"
}
}

7.

Save the template

8.

Click on Resource Group and choose TemplateRG which will fix the
location

9.

Click the Edit parameters link.

10.

For SiteName, enter a globally unique name. Suggest you use your email alias
prefix plus -webappARM so if your email address was
bsmith@contoso.com, you would use bsmith-webappARM

11.

For the Hosting Plan Name, use templateASP which will fix the location.

12. For the Site Location use the SAME value you selected for the Resource Group
Location which is displayed in the Resource Group Location link (Japan East in
the example opposite).
13. Leave the other values alone and press OK
14.

Click on Legal Terms and press Buy, to indicate that you agree with the Legal
Terms (there is no purchase involved, but some resources cost money, so that
is why Microsoft chose this word).

15.

Make sure that Pin to Startboard is selected, and the press the Create button.

4. Review What you have created


1.

Page | 3

Clcik on Resource Groups on the left Nav. You will see your templateRG group.

2.

Click the Resource Group and in the Summary of resources on the next blade you will see your App Service Plan and Your Web App. These were
the resources that were described by the template. They were created using the values you supplied to the template based on the parameters
the template needed.

3.

Click your Web Site and click Browse on the toolbar. Your site opens. It all just works.

Now you just created a template thats not too dissimilar to the template used (under the covers) when you go +New -> Web + Mobile -> Web App.

5. Create a single App Service Plan, a Web App, a SQL Server, and a SQL Database
In this task we are going to put it all together use a template that describes a more complex set of resources. Many of these templates already exisit on the
Azure Quickstart Templates gallery on GitHub.
1.

Create a new template (+New -> Marketplace Search for Template Deployment and create a template.

2.

Click on Edit Template and delete everything that is there.

3.

In a new browser window go to this link: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/201-

web-app-sql-database/azuredeploy.json copy the whole code from there and Paste it in the Edit template window replacing the
existing content.
4.

Save the template and go to the Edit parameters blade.

5.

For the Site Name, use a globally unique name.

6.

For the Hosting Plan Name we suggest you use azappplan3.

7.

For the Site Location use any one of these 4 values: West US, South Central US, Central US and East US, and then press OK.

8.

For the Server Name, use a globally unique name.

9.

For the Server Location use the same location as you used for Site Location.

10.

For Administrator login use alias + admin e.g. bsmithadmin and use a password you can remember

11.

For the Database Name we suggest you use alias-sqldbARM e.g. bsmith-sqldbARM. Press OK.

12.

On the Resource Group blade press the Or create new link, and choose FullArmRG as the name of you Resource Group.

13.

On the resource group location use the same location you used for the Site Location.

14.

On the legal terms press Buy, to indicate that you agree with the Legal Terms (there is no purchase involved, but some resources cost money, so
that is why Microsoft chose this word).

15.

Make sure that Pin to Startboard is selected, and the press the Create button.

16.

After a while, depending on the load on Azure at the time, your deployment is created and a blade with your resource group will be open.

--- END OF LAB --Go back to the AzureCon Challenge web site (http://challenge.azurecon.com) and complete the challenge question to get your points.
REMEMBER: You only have one chance at the question, make sure you really know the answer!

Page | 4

You might also like