Azure Resource Manager (ARM) Template - Beginner's Guide

juvchan 1,049 views 26 slides Apr 18, 2016
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

My presentation slide for the Global Azure Bootcamp Kuala Lumpur Malaysia 2016. Agenda includes Intro to Infrastructure-As-Code (IaC), IaC types and manifests, ARM Template intro, deployment methods, latest ARM template feature from Build 2016, ARM template deployment demo from the Quickstart templa...


Slide Content

Azure Resource Manager (ARM) Templates Beginner’s Guide Juv Chan @juvchan https://github.com/juvchan http ://stackoverflow.com/users/3203213/juvchan

About Me Infrastructure As Code ARM Template Intro ARM Template Usage – Demo ARM Template Best Practice ARM Template Troubleshooting Tips Key Takeaways Q & A Agenda

About Me

Infrastructure As Code

Programmable Infrastructure Write Code to manage configurations & automate provisioning of infra. Types: Declarative v.s. Imperative ( What v.s. How ) Developers become more involved in defining configuration Ops get involved earlier in the development process Infrastructure As Code

Declarative v.s. Imperative Declarative (What) Imperative (How) Define WHAT it should be ( Desired State ) without specifying how it is being done in details Define HOW things should be done explicitly in details step s in order to achieve the desired result "resources": [ { "type": "<resource-type-name>", "name": "<name-of-the-resource>", "location": "<location-of-resource>", " dependsOn ": [ "<array-of-related-resource-names>" ], "properties": "<settings-for-the-resource>", "resources": [ "<array-of-child-resources>" ] } ] Write-Host "Selecting subscription '$ subscriptionId '"; Set- AzureRmContext - SubscriptionID $ subscriptionId ; $ resourceGroup = Get- AzureRmResourceGroup -Name $ resourceGroupName - ErrorAction SilentlyContinue if(!$ resourceGroup ) { Write-Host "Resource group '$ resourceGroupName ' does not exist. New- AzureRmResourceGroup -Name $ resourceGroupName -Location $ resourceGroupLocation } else{ Write-Host "Using existing resource group '$ resourceGroupName '"; }

Infrastructure As Code Manifest Vendor Manifest Microsoft Azure Resource Manager (ARM) Template Chef Chef Recipe Puppet Puppet Code Amazon AWS CloudFormation Template Google Google Cloud Platform Instance Template

ARM Template

JSON file Declarative Infrastructure As Code template Defines the resources to deploy Defines input parameters, variables and outputs from the deployment Deploy resources in a single, coordinated operation ARM Template Intro

ARM Template Simplest Format { "$schema" : "http://schema.management.azure.com/schemas/2015-01-01/ deploymentTemplate.json #" , " contentVersion " : "" , "parameters" : { }, "variables" : { }, "resources" : [ ], "outputs" : { } } S ingle Template File ( xxx.template.json ) Single Template Parameter File ( xxx.param.json )

ARM Template Parameters Schema "parameters" : { "< parameterName >" : { "type" : "<type-of-parameter-value>" , " defaultValue " : "<optional-default-value-of-parameter>" , " allowedValues " : [ "<optional-array-of-allowed-values>" ], " minValue " : <optional-minimum-value- for - int -parameters>, " maxValue " : <optional-maximum-value- for - int -parameters>, " minLength " : <optional-minimum-length- for - string -secureString-array-parameters>, " maxLength " : <optional-maximum-length- for - string -secureString-array-parameters>, "metadata" : { "description" : "<optional-description-of-the parameter>" } } }

Azure Portal Azure PowerShell Azure SDK (.NET, Java, Python, Node.js, Ruby, PHP) Azure CLI (Cross-Platform Command Line Interface ) Azure Resource Manager REST API Ways to Deploy ARM Template Deployment

New feature announced in //BUILD/ 2016 To generate ARM Template from existing resources contained in a Resource Group! Export ARM Template from Resource Group

ARM Template Usage – Demo

ARM Template Best Practice

Which resources types you need to deploy ? Where those resources will reside? Which version of the resource provider API you will use? Whether any of the resources must be deployed after other resources? Which values you want to pass in during deployment, and which values you want to define directly in the template? Whether you need to return values from the deployment? Plan Your ARM Template

Best Authoring Tool – Visual Studio 2015 Define Api Versions as variables instead of parameters Use expression function e.g. trim() , toLower () to format input data Azure Quick Start Template (GitHub ) Azure Resource Manager Schema (GitHub) ARM Template Authoring Best Practices

Azure Resource Explorer ( https ://resources.azure.com / ) Azure Audit Log Azure Quick Start Template (GitHub ) Azure Resource Manager Schema (GitHub ) Stack Overflow / MSDN Forums ARM Template Troubleshooting Tips

Conclusions

Infrastructure As Code + Declarative => Desired State Configuration Resources Provision ARM Template => Best Authoring Tool + Supporting Resources More than 100 Starter templates available Key Takeaways

References

Deploy resources with Azure Resource Manager templates https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy / Infrastructure as Code with Microsoft Azure and Resource Manager https ://blogs.technet.microsoft.com/devops/2016/01/27/vorlonjs-a-journey-to-devops-infrastructure-as-code-with-microsoft-azure-and-resource-manager / Authoring Azure Resource Manager templates https ://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates / Azure Quickstart Templates https ://azure.microsoft.com/en-us/documentation/templates / Azure Resource Manager Schema https :// github.com/Azure/azure-resource-manager-schemas Resource Manager Template Walkthrough https ://azure.microsoft.com/en-us/documentation/articles/resource-manager-template-walkthrough / Useful Resources & References

Q & A

Session Evaluation Scan me: Feedback to us + Lucky draw prizes for you http://aka.ms/gab16juv malaysia.azurebootcamp.net