Quickstart: Create an Azure Cache for Redis using an ARM template

Learn how to create an Azure Resource Manager template (ARM template) that deploys an Azure Cache for Redis. The cache can be used with an existing storage account to keep diagnostic data. You also learn how to define which resources are deployed and how to define parameters that are specified when the deployment is executed. You can use this template for your own deployments, or customize it to meet your requirements. Currently, diagnostic settings are shared for all caches in the same region for a subscription. Updating one cache in the region affects all other caches in the region.

An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Deploy to Azure

Prerequisites

  • Azure subscription: If you don't have an Azure subscription, create a free account before you begin.
  • A storage account: To create one, see Create an Azure Storage account. The storage account is used for diagnostic data.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "redisCacheName": {
      "type": "string",
      "metadata": {
        "description": "Specify the name of the Azure Redis Cache to create."
      }
    },
    "location": {
      "defaultValue": "[resourceGroup().location]",
      "type": "string",
      "metadata": {
        "description": "Location of all resources"
      }
    },
    "redisCacheSKU": {
      "type": "string",
      "defaultValue": "Standard",
      "allowedValues": [
        "Basic",
        "Standard",
        "Premium"
      ],
      "metadata": {
        "description": "Specify the pricing tier of the new Azure Redis Cache."
      }
    },
    "redisCacheFamily": {
      "type": "string",
      "defaultValue": "C",
      "allowedValues": [
        "C",
        "P"
      ],
      "metadata": {
        "description": "Specify the family for the sku. C = Basic/Standard, P = Premium."
      }
    },
    "redisCacheCapacity": {
      "type": "int",
      "defaultValue": 1,
      "allowedValues": [
        0,
        1,
        2,
        3,
        4,
        5,
        6
      ],
      "metadata": {
        "description": "Specify the size of the new Azure Redis Cache instance. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4)"
      }
    },
    "enableNonSslPort": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "Specify a boolean value that indicates whether to allow access via non-SSL ports."
      }
    },
    "diagnosticsEnabled": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "Specify a boolean value that indicates whether diagnostics should be saved to the specified storage account."
      }
    },
    "existingDiagnosticsStorageAccountId": {
      "type": "string",
      "metadata": {
        "description": "Specify an existing storage account for diagnostics."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Cache/Redis",
      "apiVersion": "2020-06-01",
      "name": "[parameters('redisCacheName')]",
      "location": "[parameters('location')]",
      "properties": {
        "enableNonSslPort": "[parameters('enableNonSslPort')]",
        "minimumTlsVersion": "1.2",
        "sku": {
          "capacity": "[parameters('redisCacheCapacity')]",
          "family": "[parameters('redisCacheFamily')]",
          "name": "[parameters('redisCacheSKU')]"
        }
      },
      "resources": [
        {
          "type": "Microsoft.Cache/redis/providers/diagnosticsettings",
          "apiVersion": "2017-05-01-preview",
          "name": "[concat(parameters('redisCacheName'), '/Microsoft.Insights/', parameters('redisCacheName'))]",
          "location": "[parameters('location')]",
          "dependsOn": [
            "[resourceId('Microsoft.Cache/Redis', parameters('redisCacheName'))]"
          ],
          "properties": {
            "storageAccountId": "[parameters('existingDiagnosticsStorageAccountId')]",
            "metrics": [
              {
                "timeGrain": "AllMetrics",
                "enabled": "[parameters('diagnosticsEnabled')]",
                "retentionPolicy": {
                  "days": 90,
                  "enabled": "[parameters('diagnosticsEnabled')]"
                }
              }
            ]
          }
        }
      ]
    }
  ]
}

The following resources are defined in the template:

Resource Manager templates for the new Premium tier are also available.

To check for the latest templates, see Azure Quickstart Templates and search for Azure Cache for Redis.

Deploy the template

  1. Select the following image to sign in to Azure and open the template.

    Deploy to Azure

  2. Select or enter the following values:

    • Subscription: select an Azure subscription used to create the data share and the other resources.
    • Resource group: select Create new to create a new resource group or select an existing resource group.
    • Location: select a location for the resource group. The storage account and the Redis cache must be in the same region. By default the Redis cache uses the same location as the resource group. So, specify the same location as the storage account.
    • Redis Cache Name: enter a name for the Redis cache.
    • Existing Diagnostics Storage Account: enter the resource ID of a storage account. The syntax is /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<STORAGE ACCOUNT NAME>.

    Use the default value for the rest of the settings.

  3. select I agree to the terms and conditions stated above, and the select Purchase.

Review deployed resources

  1. Sign in to the Azure portal.
  2. Open the Redis cache that you created.

Clean up resources

When no longer needed, delete the resource group, which deletes the resources in the resource group.

$resourceGroupName = Read-Host -Prompt "Enter the resource group name"
Remove-AzResourceGroup -Name $resourceGroupName
Write-Host "Press [ENTER] to continue..."

Next steps

In this tutorial, you learnt how to create an Azure Resource Manager template that deploys an Azure Cache for Redis. To learn how to create an Azure Resource Manager template that deploys an Azure Web App with Azure Cache for Redis, see Create a Web App plus Azure Cache for Redis using a template.