Deploy services using Azure Resource Manager templates
Objective
Scenario
Virtual Machines
- TR22 Base Windows 10
Exercise 1 : Deploying Services using ARM Templates
In this task we are going to create a deployment using an ARM Template to deploy a single App Service Plan.
- Create a single App Service Plan (Hosting Plan)Log in to your Azure account at https://portal.azure.com
- In the top-left corner of the portal click + NewIn the top-left corner of the portal click + New.
- In the search box at the topIn the search box at the top, start typing “Template deployment” and select the Template deployment option.
- Click the Template deployment itemClick the Template deployment item and click Create.
- Click Edit TemplateClick 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, you need to specify the region a resource needs to be deployed into. Templates can also describe dependencies between resources, such as a set of ordered instructions.
- When you deploy services themselves in AzureWhen 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.
- On the Edit template bladeOn the Edit template blade locate the line containing his code:"parameters": {}. This should be line 4. Between the braces (“{ }”) put the following:
"hostingPlanName": {
"type": "string",
"metadata": {
"description": "The name of the App Service plan to use for hosting the web app."
}
},
"siteLocation": {
"type": "string",
"metadata": {
"description": "The location to use for creating the web app and hosting plan."
}
},
"sku": {
"type": "string",
"allowedValues": [
"Free",
"Shared",
"Basic",
"Standard"
],
"defaultValue": "Free",
"metadata": {
"description": "The pricing tier for the hosting plan."
}
},
"workerSize": {
"type": "string",
"allowedValues": [
"0",
"1",
"2"
],
"defaultValue": "0",
"metadata": {
"description": "The instance size of the hosting plan (small, medium, or large)."
}
} - The configuration aboveThe configuration above defines the parameters that will be used for the template.
- Next, update the resources propertyNext, update the resources property (the area between the brackets “[ ]”) with the following.
"resources": [{
"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 configuration defines the servicesThis configuration defines the services that need to be created, in this case an Application Plan.
- In order to make your life easier for next taskIn order to make your life easier for the next tasks, copy the whole configuration into a new instance of Notepad.
- Go back to the portal and press SaveGo back to the portal and press Save.
- From the Resource group dropdown, select + NewFrom the Resource group dropdown, select + New.
- Enter “templateRG”Enter “templateRG” as the New resource group location.
- Click on Resource group locationClick on Resource group location and select any of the available regions.
- Click the Edit parameters linkClick the Edit parameters link.
- For the HOSTINGPLANNAME, use “templateASP”For the HOSTINGPLANNAME, use “templateASP”.
- For the SITELOCATIONFor the SITELOCATION, use the same value you selected for the Resource group location which is displayed in the Resource group location link (“West US” in this example).
- Leave the other values alone and press OKLeave the other values alone and press OK
- Click on Legal Terms and press PurchaseClick on Legal Terms and press Purchase to indicate that you agree with the Legal Terms.
- Make sure that Pin to dashboard is selectedMake sure that Pin to dashboard is selected, and the press the Create.
It will take a moment for your app service plan to become available.
Click Continue to advance to the next exercise.
Exercise 2 : Create a single App Service Plan and a Web App
- You are going to repeat creating the templateYou are going to repeat creating the template you did in the previous task, but you have all this copied in Notepad ready to go.
- Create a new templateCreate a new template (+New, search for “Template deployment”, all the way through the first Create to start creating the template).
- Click Edit templateClick Edit template and delete everything that is there.
- Switch to NotepadSwitch to Notepad where you old template definition is waiting. Copy it to the portal to replace the existing default template.
- In the parameters sectionIn the parameters section, add the following parameter at the beginning of the list, right after the opening “{“.
"siteName": {
"type": "string",
"metadata": {
"description": "The name of the web app that you wish to create."
}
}, - In the resources sectionIn the resources section add a comma after the existing resource, directly before the last “]” closing square bracket and then add the resource below.
{
"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')]"
}
}
- Save the templateSave the template.
- Click on Resource groupClick on Resource group and choose “templateRG”, which will fix the location.
- Click the Edit parameters linkClick the Edit parameters link.
- For SITENAME, enterFor SITENAME, enter a globally unique name. Consider using your name plus “-webappARM”, such as “johndoe-webappARM”.
- For the HOSTINGPLANNAMEFor the HOSTINGPLANNAME, use “templateASP” – which will fix the location.
- For the SITELOCATIONFor the SITELOCATION use the same value you selected for the Resource Group Location which is displayed in the Resource group location link.
- Leave the other values alone and press OKLeave the other values alone and press OK.
- Click on Legal TermsClick on Legal Terms and press Purchase to indicate that you agree with the Legal Terms.
- Make sure that Pin to dashboard is selectedMake sure that Pin to dashboard is selected, and the press the Create.It will take a moment for your app service plan to become available.
Click Continue to advance to the next exercise.
Exercise 3 : Review what you have created
- Click the Resource groupsClick the Resource groups item from the portal’s left menu.
- Click your “templateRG” item to open itClick your “templateRG” item to open it.
- In the Summary sectionThe Summary blade lists your App Service Plan and your Web app (App Service). 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.
- Click your Web siteClick your Web site and click the Browse button on the toolbar. Your site opens. It all just works.
- What you just createdWhat you just created is a template that’s similar to the template used (under the covers) if you had created it from +New | Web + Mobile | Web App.
Click Continue to advance to the next exercise.
Exercise 4 : Create a single App Service Plan, a Web App, a SQL Server, and a SQL Database
- Create a new templateCreate a new template (+New, search for “Template deployment”, all the way through the first Create to start creating the template).
- Click Edit TemplateClick Edit Template and delete everything that is there.
- In a new browser windowIn a new browser window go to https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/201-web-app-sql-database/azuredeploy.json.
- Copy the whole contentCopy the whole content from there and paste it in the Edit template blade.
- Save the templateSave the template and go to the Edit parameters blade.
- For ADMINISTRATORLOGINFor ADMINISTRATORLOGIN, use name + “admin”, such as “johndoeadmin”. Select a password you can remember.
- For DATABASENAMEFor DATABASENAME, we suggest you use name + “-sqldbARM”, such as “johndoe-sqldbARM”.
- Press OKPress OK.
- From the Resource group dropdownFrom the Resource group dropdown, select + New.
- Enter “FullArmRG”Enter “FullArmRG” as the New resource group location.
- Click on Resource group locationClick on Resource group location and select the same region used in earlier steps.
- Click on Legal Terms and press CreateClick on Legal Terms and press Create to indicate that you agree with the Legal Terms.
- Make sure that Pin to dashboard is selectedMake sure that Pin to dashboard is selected, and the press the Create.
- Deployment is createdAfter 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.
Click Continue to advance to the next exercise.
No comments:
Post a Comment