Skip to content

Latest commit

 

History

History
95 lines (85 loc) · 4.63 KB

4.1.4. Deploying ARM templates (Azure Building Blocks).md

File metadata and controls

95 lines (85 loc) · 4.63 KB

Deploying ARM templates

Problem definition

  • Authoring and deployment of ARM templates can be hard:
    • Become very complex in a short amount of time.
    • Difficult to ensure that Microsoft best practices for Azure infrastructure are reflected in every template authored by your team.
  • Development of your templates follows a pattern:
    • E.g.:
      1. JSON object for a virtual network
      2. JSON object for virtual machines that are deployed into the virtual network.
      3. JSON object for a network security group to secure the virtual network.
      4. JSON object for a load balancer to distribute incoming requests to the virtual machines
  • Problem:
    • Great deal of knowledge about Azure Resource Manager and the resources themselves.
    • Difficulty maintaining your templates because any modification can lead to unforeseen issues.

Azure Building Blocks

  • Command line tool and set of ARM templates.
    • Reflect best practices as prescribed by the Patterns & Practices team at Microsoft.
  • Designed to simplify deployment of Azure resources.
  • Flow:
    1. Specify settings for Azure resources using the Building Blocks JSON schema
      • You can either specify your resources settings in one large file or several small files.
      • Supports: • Virtual Networks • Virtual Machines (including load balancers) • Virtual Machine Extensions • Route Tables • Network Security Groups • Virtual Network Gateways • Virtual Network Connection
    2. Command line tool merges these settings with best practice defaults (from GitHub templates) to produce a set of parameter files
    3. The command line tool deploys these parameter files using a set of pre-built Azure Resource Manager templates

Deploying resources using building blocks

  1. Install azbb* command line tool and the Azure CLI.

  2. Create building blocks

    • Create a JSON file with a buildingBlocks parameter containing an array of resources that you wish to deploy.
      • Each resource within that JSON array can have certain options configured.
      • E.g. Virtual Network resource => addressPrefix_, subnets_ and name.
      • Any options you do not specify are set using the default options specified in the building blocks repository.
      • E.g. deploying a Virtual Network includes following properties:
        • type :identify the type of building block. E.g. VirtualNetwork.
        • name : Unique name of the resource
        • addressPrefixes : Array of address ranges in CIDR notation.
          • E.g.: "addressPrefixes": [ "10.0.0.0/16", "11.0.0.0/16" ]
        • subnets :ian array—we can specify up to 1,000 subnets for each VNet.
  3. Create a settings file

    • Run the azbb command line tool to parse your settings and combine it with the default settings from the building blocks repository

      • The azbb command line tool will output an ARM template parameters file,
    • Empty settings file:

       {
         "$schema": "https://raw.githubusercontent.com/mspnp/template-building-blocks/master/schemas/buildingBlocks.json",
         "contentVersion": "1.0.0.0",
         "parameters" : { "buildingBlocks": { "value": [ {} ] } }
       }
    • E.g. deploying a Virtual Network

         {
           "$schema": "https://raw.githubusercontent.com/mspnp/template-building-blocks/master/schemas/buildingBlocks.json",
           "contentVersion": "1.0.0.0",
           "parameters": {
             "buildingBlocks": {
               "value": [
                 {
                   "type": "VirtualNetwork",
                   "settings": [
                     {
                       "name": "msft-hub-vnet",
                       "addressPrefixes": [
                         "10.0.0.0/16"
                       ],
                       "subnets": [
                         {
                           "name": "firewall",
                           "addressPrefix": "10.0.1.0/24"
                         }
                       ]
                     }
                   ]
                 }
               ]
             }
           }
         }
  4. Deploy

    • azbb tool will use the Azure CLI (version 2.0) to deploy the master ARM template from the building blocks repository using the parameters file that was generated.
      • The Azure deployment will create a collection of resources within an Azure Resource Group.
        • It'll have historical deployment information
          • You can go back and view the template and parameters used by the building blocks command line tool to deploy your resources.
    • Command:
      • azbb -g <new or existing resource group> -s <subscription ID> -l <region> -p <path to your settings file> --deploy