Date post: | 19-Jan-2017 |
Category: |
Technology |
Upload: | juv-chan |
View: | 212 times |
Download: | 0 times |
#GlobalAzure
Azure Resource Manager (ARM) Templates Beginner’s Guide
Juv Chan @juvchan https://github.com/juvchan http://stackoverflow.com/users/3203213/juvchan
#GlobalAzure
• 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
#GlobalAzure
About Me
#GlobalAzure
#GlobalAzure
Infrastructure As Code
#GlobalAzure
• 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
#GlobalAzure
Declarative v.s. ImperativeDeclarative (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 steps 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'"; }
#GlobalAzure
Infrastructure As Code ManifestVendor Manifest
Microsoft Azure Resource Manager (ARM) Template
Chef Chef Recipe
Puppet Puppet Code
Amazon AWS CloudFormation Template
Google Google Cloud Platform Instance Template
#GlobalAzure
ARM Template
#GlobalAzure
• 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
#GlobalAzure
ARM Template Simplest Format{ "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "", "parameters": { }, "variables": { }, "resources": [ ], "outputs": { } }
• Single Template File (xxx.template.json)• Single Template Parameter File (xxx.param.json)
#GlobalAzure
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>" } } }
#GlobalAzure
• 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
#GlobalAzure
• New feature announced in //BUILD/ 2016
• To generate ARM Template from existing resources contained in a Resource Group!
Export ARM Template from Resource Group
#GlobalAzure
ARM Template Usage – Demo
#GlobalAzure
ARM Template Best Practice
#GlobalAzure
• 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
#GlobalAzure
• 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
#GlobalAzure
• 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
#GlobalAzure
Conclusions
#GlobalAzure
• Infrastructure As Code + Declarative => Desired State Configuration Resources Provision
• ARM Template => Best Authoring Tool + Supporting Resources
• More than 100 Starter templates available
Key Takeaways
#GlobalAzure
References
#GlobalAzure
•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
#GlobalAzure
Q & A
#GlobalAzure
Session EvaluationScan me:
Feedback to us+
Lucky draw prizes for you
http://aka.ms/gab16juv malaysia.azurebootcamp.net