Quickstart: Create and deploy Azure Resource Manager templates by using the Azure portal

Learn how to create your first Azure Resource Manager template by generating one using the Azure portal, and the process of editing and deploying the template from the Azure portal. Resource Manager templates are JSON files that define the resources you need to deploy for your solution. The instructions in this tutorial create an Azure Storage account. You can use the same process to create other Azure resources.

If you don't have an Azure subscription, create a free account before you begin.

Generate a template using the portal

In this section, you create a storage account using the Azure portal. Before you deploy the storage account, you have the option to explore the template generated by the portal based on your configurations. You can save the template and reuse it in the future.

  1. Sign in to the Azure portal.
  2. Select Create a resource > Storage > Storage account - blob, file, table, queue.

    Create an Azure storage account using the Azure portal

  3. Enter the following information.

    • Resource group: create a new Azure resource group with the name of your choice. On the screenshot, the resource group name is mystorage1016rg.
    • Name: give your storage account a unique name. On the screenshot, the name is mystorage1016.

      You can use the default values for the rest of the properties.

      Create an Azure storage account configuration using the Azure portal

      Note

      Some of the exported templates require some edits before you can deploy them.

  4. Select Review + create on the bottom of the screen.

  5. Select Download a template for automation on the bottom of the screen. The portal shows the generated template:

    Generate a template from the portal

    The main pane shows the template. It is a JSON file with four top-level elements - schema, contentVersion, parameters and resources. For more information, see Understand the structure and syntax of Azure Resource Manager Templates

    There are six parameters defined. One of them is called storageAccountName. The second highlighted part shows how to use this parameter in the template. In the next section, you edit the template to use a generated name for the storage account.

    In the template, one Azure resource is defined. The type is [Microsoft.Storage/storageAccounts]. See how the resource is defined, and the definition structure.

  6. Select Download. Save template.json from the downloaded package to your computer. In the next section, you use a template deployment tool to edit the template.
  7. Select the Parameter tab to see the values you provided for the parameters. Write down these values, you need them in the next section when you deploy the template.

    Generate a template from the portal

    Using both the template and the parameters files, you can create an Azure storage account.

Edit and deploy the template

The Azure portal can be used to perform some basic template editing. In this quickstart, you use a portal tool called Template Deployment. To edit a more complex template, consider using Visual Studio Code which provides richer edit functionalities.

Azure requires that each Azure service has a unique name. The deployment fails if you enter a storage account name that already exists. To avoid this issue, you can use a template function call uniquestring() to generate a unique storage account name.

  1. In the Azure portal, select Create a resource.
  2. In Search the Marketplace, type template deployment, and then press ENTER.
  3. Select Template deployment.

    Azure Resource Manager templates library

  4. Select Create.
  5. Select Build your own template in the editor.
  6. Select Load file, and then follow the instructions to load template.json you downloaded in the last section.
  7. Add one variable as shown in the following screenshot:

    "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]"
    

    Azure Resource Manager templates

    Two functions are used here: concat() and uniqueString().

  8. Remove the storageAccountName parameter highlighted in the previous screenshot.

  9. Update the name element of the Microsoft.Storage/storageAccounts resource to use the newly defined variable instead of the parameter:

    "name": "[variables('storageAccountName')]",
    

    The final template shall look like:

    {
        "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "location": {
                "type": "string"
            },
            "accountType": {
                "type": "string"
            },
            "kind": {
                "type": "string"
            },
            "accessTier": {
                "type": "string"
            },
            "supportsHttpsTrafficOnly": {
                "type": "bool"
            }
        },
        "variables": {
            "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]"
        },
        "resources": [
            {
                "name": "[variables('storageAccountName')]",
                "type": "Microsoft.Storage/storageAccounts",
                "apiVersion": "2018-07-01",
                "location": "[parameters('location')]",
                "properties": {
                    "accessTier": "[parameters('accessTier')]",
                    "supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]"
                },
                "dependsOn": [],
                "sku": {
                    "name": "[parameters('accountType')]"
                },
                "kind": "[parameters('kind')]"
            }
        ],
        "outputs": {}
    }
    
  10. Select Save.
  11. Enter the following values:

    • Resource group: name your resource group with a unique name.
    • Location: select a location for the resource group.
    • Location: select a location for the storage account. You can use the same location as the resource group.
    • Account Type: Enter Standard_LRS for this quickstart.
    • Kind: Enter StorageV2 for this quickstart.
    • Access Tier: Enter Hot for this quickstart.
    • Https Traffic Only Enabled. Select true for this quickstart.
    • I agree to the terms and conditions stated above: (select)

      Here is a screenshot of a sample deployment:

      Azure Resource Manager templates deployment

  12. Select Purchase.

  13. Select the bell icon (notifications) from the top of the screen to see the deployment status. Wait until the deployment is completed.

    Azure Resource Manager templates deployment notification

  14. Select Go to resource group from the notification pane. You shall see a screen similar to:

    Azure Resource Manager templates deployment resource group

    You can see the deployment status was successful, and there is only one storage account in the resource group. The storage account name is a unique string generated by the template. To learn more about using Azure storage accounts, see Quickstart: Upload, download, and list blobs using the Azure portal.

Clean up resources

When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group.

  1. In the Azure portal, select Resource group on the left menu.
  2. Enter the resource group name in the Filter by name field.
  3. Select the resource group name. You shall see the storage account in the resource group.
  4. Select Delete resource group in the top menu.

Next steps

In this tutorial, you learned how to generate a template from the Azure portal, and how to deploy the template using the portal. The template used in this Quickstart is a simple template with one Azure resource. When the template is complex, it is easier to use Visual Studio Code or Visual Studio to develop the template. The next quickstart also shows you how to deploy templates using Azure PowerShell and Azure Command-line Interface (CLI).