Creating a T-shirt size ARM template

Create known configuration in your ARM templates with T-shirt sizes

A good way of keeping on top of the configurations deployed in your Azure environment can be done by using T-shirt size configurations. T-shirt Sizes are known working configurations for your ARM templates. By using a T-shirt Size you can take away the complexity from the ARM template consumers. A sample of a T-shirt Size can be a Small, Medium of Large offering from a resource.

In this blogpost I want to show how you can use T-shirt Size configuration in an ARM template. The idea is to deploy a website where you hide all the size setting behind a Small, Medium of Large sizing. The consumer only has two parameters to start the deployment:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webSiteName": {
      "value": "tshirtsizewebapptest"
    },
    "webAppSize": {
      "value": "Small"
    }
  }
}

The ARM with T-shirt size will look like:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webSiteName": {
      "type": "string",
      "minLength": 2
    },
    "webAppSize": {
      "type": "string",
      "defaultValue": "Small",
      "allowedValues": [
        "Small",
        "Medium",
        "Large"
      ]
    }
  },
  "variables": {
    "tshirtSize": "[variables(concat('tshirtSize',parameters('webAppSize')))]",
    "tshirtSizeSmall": {
      "skuName": "S1",
      "skuCapacity": 1
    },
    "tshirtSizeMedium": {
      "skuName": "S2",
      "skuCapacity": 2
    },
    "tshirtSizeLarge": {
      "skuName": "S3",
      "skuCapacity": 3
    },
    "hostingPlanName": "[concat(parameters('webSiteName'),'hp')]"
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "[variables('hostingPlanName')]",
      "type": "Microsoft.Web/serverfarms",
      "location": "[resourceGroup().location]",
      "tags": {
        "displayName": "HostingPlan"
      },
      "sku": {
        "name": "[variables('tshirtSize').skuName]",
        "capacity": "[variables('tshirtSize').skuCapacity]"
      },
      "properties": {
        "name": "[variables('hostingPlanName')]"
      }
    },
    {
      "apiVersion": "2015-08-01",
      "name": "[parameters('webSiteName')]",
      "type": "Microsoft.Web/sites",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]": "Resource",
        "displayName": "Website"
      },
      "dependsOn": [
        "[concat('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
      ],
      "properties": {
        "name": "[parameters('webSiteName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
        "siteConfig": {
          "alwaysOn": true,
          "remoteDebuggingVersion": "VS2015",
          "use32BitWorkerProcess": false
        }
      }
    }
  ]
}

As you can see in the template the variable section contains the T-shirt sizes. In this template 2 variables are configured: skuName, skuCapacity. The usage of the sizing is: “[variables(‘tshirtSize’).skuCapacity]”.

Then you can publish with powershell by running:

Login-AzureRmAccount
New-AzureRmResourceGroup -Name rgtshirtsizetestdeployment -Location "West Europe"
New-AzureRmResourceGroupDeployment -Name rgtshirtsizetestdeployment-23 -ResourceGroupName rgtshirtsizetestdeployment -TemplateFile .\azuredeploy.json -TemplateParameterFile .\azuredeploy.parameters.json

A next step is to publish the ARM templates from a central point in your organization and then use them as linked ARM templates in your projects. This way you can share the known working configurations in your organization over different teams.

More information on T-shirt sizing can be found in the following white paper: World class ARM templates or best practices resource manager design templates.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.