Deploying Resources to Azure using Azure Resource Manager Templates - Part #3

In the previous post, I had already explained the steps that are needed for deployment in Azure using an empty template. Let's explore further and see how we can deploy a storage account in Azure using ARM Templates.

Step 1: Create the template file

Open any text editor and create a template like the one given below. Save it as a JSON file with name StorageTemplate.json
What we are doing with this template is that we have defined two parameters named storageName and storageLocation for accepting the name of the resource as well as the location where it needs to be provisioned

And, under the resource section, we will use these parameters to set the name and the location properties for the storage account. Also, we will set the values for the resource type, kind and SKU

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.1",
    "parameters": {
        "storageName": {
            "type": "string"
        },
        "storageLocation": {
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
          "apiVersion": "2016-01-01",
          "type": "Microsoft.Storage/storageAccounts",
          "name":  "[parameters('storageName')]",
          "location": "[parameters('storageLocation')]",  
          "sku": {
            "name": "Standard_LRS"
          },
          "kind": "Storage",
          "properties": {
          }
        }
   
    ],
    "outputs": {}
}


Step 2: Deploy the template using Azure CLI

Open up Powershell/Command prompt and execute the following command. Make sure that Azure CLI is already installed in your machine and configured to access your Azure subscription

az group deployment create --name EmptyARMDeployment --resource-group TechRepResGrp --template-file .\storage-template.json --parameters storageName=storagedemoO365 storageLocation=SouthIndia

This command is very much similar to the one we used in the earlier post, the only difference is that we supplied the values for the parameters that will be used by the template to provision the storage account


No Comments

Add a Comment