빠른 시작: ARM 템플릿을 사용하여 Azure Cache for Redis 만들기

Azure Cache for Redis를 배포하는 ARM 템플릿(Azure Resource Manager 템플릿)을 만드는 방법에 대해 알아봅니다. 기존 스토리지 계정과 함께 캐시를 사용하여 진단 데이터를 유지할 수 있습니다. 어떤 리소스를 배포할지 정의하는 방법 및 배포를 실행할 때 매개 변수를 지정하는 방법도 알아봅니다. 배포를 위해 이 템플릿을 사용하거나 요구 사항에 맞게 사용자 지정을 할 수 있습니다. 현재 진단 설정은 구독에 대한 동일한 지역의 모든 캐시에서 공유됩니다. 지역의 캐시 하나를 업데이트하면 해당 지역의 다른 모든 캐시에 영향을 줍니다.

Azure Resource Manager 템플릿은 프로젝트의 인프라 및 구성을 정의하는 JSON(JavaScript Object Notation) 파일입니다. 이 템플릿은 선언적 구문을 사용합니다. 배포를 만들기 위한 프로그래밍 명령 시퀀스를 작성하지 않고 의도한 배포를 설명합니다.

환경이 필수 구성 요소를 충족하고 ARM 템플릿 사용에 익숙한 경우 Azure에 배포 단추를 선택합니다. 그러면 Azure Portal에서 템플릿이 열립니다.

Button to deploy the Resource Manager template to Azure.

필수 조건

  • Azure 구독: Azure 구독이 아직 없는 경우 시작하기 전에 체험 계정을 만듭니다.
  • 스토리지 계정: 계정을 만들려면 Azure Storage 계정 만들기를 참조하세요. 스토리지 계정은 진단 데이터에 사용됩니다.

템플릿 검토

이 빠른 시작에서 사용되는 템플릿은 Azure 빠른 시작 템플릿에서 나온 것입니다.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.22.6.54827",
      "templateHash": "17110451938184928271"
    }
  },
  "parameters": {
    "redisCacheName": {
      "type": "string",
      "defaultValue": "[format('redisCache-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Specify the name of the Azure Redis Cache to create."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "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, 5)"
      }
    },
    "builtInAccessPolicyName": {
      "type": "string",
      "defaultValue": "Data Reader",
      "allowedValues": [
        "Data Owner",
        "Data Contributor",
        "Data Reader"
      ],
      "metadata": {
        "description": "Specify name of Built-In access policy to use as assignment."
      }
    },
    "builtInAccessPolicyAssignmentName": {
      "type": "string",
      "defaultValue": "[format('builtInAccessPolicyAssignment-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Specify name of custom access policy to create."
      }
    },
    "builtInAccessPolicyAssignmentObjectId": {
      "type": "string",
      "defaultValue": "[newGuid()]",
      "metadata": {
        "description": "Specify the valid objectId(usually it is a GUID) of the Microsoft Entra Service Principal or Managed Identity or User Principal to which the built-in access policy would be assigned."
      }
    },
    "builtInAccessPolicyAssignmentObjectAlias": {
      "type": "string",
      "defaultValue": "[format('builtInAccessPolicyApplication-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Specify human readable name of principal Id of the Microsoft Entra Application name or Managed Identity name used for built-in policy assignment."
      }
    },
    "customAccessPolicyName": {
      "type": "string",
      "defaultValue": "[format('customAccessPolicy-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Specify name of custom access policy to create."
      }
    },
    "customAccessPolicyPermissions": {
      "type": "string",
      "defaultValue": "+@connection +get +hget allkeys",
      "metadata": {
        "description": "Specify the valid permissions for the customer access policy to create. For details refer to https://aka.ms/redis/ConfigureAccessPolicyPermissions"
      }
    },
    "customAccessPolicyAssignmentName": {
      "type": "string",
      "defaultValue": "[format('customAccessPolicyAssignment-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Specify name of custom access policy to create."
      }
    },
    "customAccessPolicyAssignmentObjectId": {
      "type": "string",
      "defaultValue": "[newGuid()]",
      "metadata": {
        "description": "Specify the valid objectId(usually it is a GUID) of the Microsoft Entra Service Principal or Managed Identity or User Principal to which the custom access policy would be assigned."
      }
    },
    "customAccessPolicyAssignmentObjectAlias": {
      "type": "string",
      "defaultValue": "[format('customAccessPolicyApplication-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Specify human readable name of principal Id of the Microsoft Entra Application name or Managed Identity name used for custom policy assignment."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Cache/redis",
      "apiVersion": "2023-08-01",
      "name": "[parameters('redisCacheName')]",
      "location": "[parameters('location')]",
      "properties": {
        "enableNonSslPort": false,
        "minimumTlsVersion": "1.2",
        "sku": {
          "capacity": "[parameters('redisCacheCapacity')]",
          "family": "[parameters('redisCacheFamily')]",
          "name": "[parameters('redisCacheSKU')]"
        },
        "redisConfiguration": {
          "aad-enabled": "true"
        }
      }
    },
    {
      "type": "Microsoft.Cache/redis/accessPolicyAssignments",
      "apiVersion": "2023-08-01",
      "name": "[format('{0}/{1}', parameters('redisCacheName'), parameters('builtInAccessPolicyAssignmentName'))]",
      "properties": {
        "accessPolicyName": "[parameters('builtInAccessPolicyName')]",
        "objectId": "[parameters('builtInAccessPolicyAssignmentObjectId')]",
        "objectIdAlias": "[parameters('builtInAccessPolicyAssignmentObjectAlias')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Cache/redis', parameters('redisCacheName'))]"
      ]
    },
    {
      "type": "Microsoft.Cache/redis/accessPolicies",
      "apiVersion": "2023-08-01",
      "name": "[format('{0}/{1}', parameters('redisCacheName'), parameters('customAccessPolicyName'))]",
      "properties": {
        "permissions": "[parameters('customAccessPolicyPermissions')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Cache/redis', parameters('redisCacheName'))]",
        "[resourceId('Microsoft.Cache/redis/accessPolicyAssignments', parameters('redisCacheName'), parameters('builtInAccessPolicyAssignmentName'))]"
      ]
    },
    {
      "type": "Microsoft.Cache/redis/accessPolicyAssignments",
      "apiVersion": "2023-08-01",
      "name": "[format('{0}/{1}', parameters('redisCacheName'), parameters('customAccessPolicyAssignmentName'))]",
      "properties": {
        "accessPolicyName": "[parameters('customAccessPolicyName')]",
        "objectId": "[parameters('customAccessPolicyAssignmentObjectId')]",
        "objectIdAlias": "[parameters('customAccessPolicyAssignmentObjectAlias')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Cache/redis', parameters('redisCacheName'))]",
        "[resourceId('Microsoft.Cache/redis/accessPolicies', parameters('redisCacheName'), parameters('customAccessPolicyName'))]"
      ]
    }
  ]
}

다음 리소스는 템플릿에 정의되어 있습니다.

프리미엄 계층을 위한 Resource Manager 템플릿을 사용할 수 있습니다.

최신 템플릿을 확인하려면 Azure 빠른 시작 템플릿을 참조하고 Azure Cache for Redis를 검색하세요.

템플릿 배포

  1. 다음 이미지를 선택하여 Azure에 로그인하고 템플릿을 엽니다.

    Button to deploy the Resource Manager template to Azure.

  2. 다음 값을 선택하거나 입력합니다.

    • 구독: 데이터 공유 및 기타 리소스를 만드는 데 사용되는 Azure 구독을 선택합니다.
    • 리소스 그룹: 새로 만들기를 선택하여 새 리소스 그룹을 만들거나 기존 리소스 그룹을 선택합니다.
    • 위치: 리소스 그룹에 대한 위치를 선택합니다. 스토리지 계정과 Redis Cache는 동일한 지역에 있어야 합니다. 기본적으로 Redis Cache는 리소스 그룹과 동일한 위치를 사용합니다. 따라서 스토리지 계정과 동일한 위치를 지정합니다.
    • Redis Cache 이름: Redis Cache의 이름을 입력합니다.
    • 기존 진단 스토리지 계정: 스토리지 계정의 리소스 ID를 입력합니다. 구문은 /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Storage/storageAccounts/<STORAGE ACCOUNT NAME>입니다.

    나머지 설정에 대해서는 기본값을 사용합니다.

  3. 위에 명시된 사용 약관에 동의함을 선택한 다음, 구매를 선택합니다.

배포된 리소스 검토

  1. Azure Portal에 로그인합니다.
  2. 만든 Redis Cache를 엽니다.

리소스 정리

더 이상 필요 없으면 리소스 그룹을 삭제합니다. 그러면 리소스 그룹의 리소스가 삭제됩니다.

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

다음 단계

이 자습서에서는 Azure Cache for Redis를 배포하는 Azure Resource Manager 템플릿을 만드는 방법에 대해 알아봅니다. Azure Cache for Redis를 사용하여 Azure 웹앱을 배포하는 Azure Resource Manager 템플릿을 만드는 방법에 대한 자세한 내용은 템플릿을 사용하여 Azure Cache for Redis가 포함된 웹앱 만들기를 참조하세요.