Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Pelajari cara menggunakan Bicep untuk sebarkan cache menggunakan Azure Cache for Redis. Setelah Anda sebarkan cache, gunakan dengan akun penyimpanan yang ada untuk menyimpan data diagnostik. Pelajari cara menentukan sumber daya mana yang disebar dan cara menentukan beberapa parameter yang ditentukan saat penyebaran dijalankan. Anda dapat menggunakan file ini untuk sebarkan Anda sendiri, atau sesuaikannya untuk memenuhi persyaratan Anda.
Bicep adalah bahasa pemrogram khusus domain (DSL) yang menggunakan sintaks deklaratif untuk menyebarkan sumber daya Azure. Ini menyediakan sintaks yang ringkas, keamanan jenis yang dapat diandalkan, dan dukungan untuk penggunaan kembali kode. Bicep menawarkan pengalaman penulisan terbaik untuk solusi infrastructure-as-code di Azure.
Prasyarat
- Langganan Azure: Jika Anda tidak memiliki langganan Azure, buat akun gratis sebelum memulai.
- Akun penyimpanan: Untuk membuatnya, lihat Membuat akun Azure Storage. Akun penyimpanan digunakan untuk data diagnostik. Buat akun penyimpanan baru di grup sumber daya bernama exampleRG.
Azure Cache for Redis
Tinjau ulang file Bicep
File Bicep yang digunakan dalam quickstart ini berasal dari Azure Quickstart Templates.
@description('Specify the name of the Azure Redis Cache to create.')
param redisCacheName string = 'redisCache-${uniqueString(resourceGroup().id)}'
@description('Location of all resources')
param location string = resourceGroup().location
@description('Specify the pricing tier of the new Azure Redis Cache.')
@allowed([
'Basic'
'Standard'
'Premium'
])
param redisCacheSKU string = 'Standard'
@description('Specify the family for the sku. C = Basic/Standard, P = Premium.')
@allowed([
'C'
'P'
])
param redisCacheFamily string = 'C'
@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)')
@allowed([
0
1
2
3
4
5
6
])
param redisCacheCapacity int = 1
@description('Specify name of Built-In access policy to use as assignment.')
@allowed([
'Data Owner'
'Data Contributor'
'Data Reader'
])
param builtInAccessPolicyName string = 'Data Reader'
@description('Specify name of custom access policy to create.')
param builtInAccessPolicyAssignmentName string = 'builtInAccessPolicyAssignment-${uniqueString(resourceGroup().id)}'
@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.')
param builtInAccessPolicyAssignmentObjectId string = newGuid()
@description('Specify human readable name of principal Id of the Microsoft Entra Application name or Managed Identity name used for built-in policy assignment.')
param builtInAccessPolicyAssignmentObjectAlias string = 'builtInAccessPolicyApplication-${uniqueString(resourceGroup().id)}'
@description('Specify name of custom access policy to create.')
param customAccessPolicyName string = 'customAccessPolicy-${uniqueString(resourceGroup().id)}'
@description('Specify the valid permissions for the customer access policy to create. For details refer to https://aka.ms/redis/ConfigureAccessPolicyPermissions')
param customAccessPolicyPermissions string = '+@connection +get +hget allkeys'
@description('Specify name of custom access policy to create.')
param customAccessPolicyAssignmentName string = 'customAccessPolicyAssignment-${uniqueString(resourceGroup().id)}'
@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.')
param customAccessPolicyAssignmentObjectId string = newGuid()
@description('Specify human readable name of principal Id of the Microsoft Entra Application name or Managed Identity name used for custom policy assignment.')
param customAccessPolicyAssignmentObjectAlias string = 'customAccessPolicyApplication-${uniqueString(resourceGroup().id)}'
resource redisCache 'Microsoft.Cache/redis@2023-08-01' = {
name: redisCacheName
location: location
properties: {
enableNonSslPort: false
minimumTlsVersion: '1.2'
sku: {
capacity: redisCacheCapacity
family: redisCacheFamily
name: redisCacheSKU
}
redisConfiguration: {
'aad-enabled': 'true'
}
}
}
resource redisCacheBuiltInAccessPolicyAssignment 'Microsoft.Cache/redis/accessPolicyAssignments@2023-08-01' = {
name: builtInAccessPolicyAssignmentName
parent: redisCache
properties: {
accessPolicyName: builtInAccessPolicyName
objectId: builtInAccessPolicyAssignmentObjectId
objectIdAlias: builtInAccessPolicyAssignmentObjectAlias
}
}
resource redisCacheCustomAccessPolicy 'Microsoft.Cache/redis/accessPolicies@2023-08-01' = {
name: customAccessPolicyName
parent: redisCache
properties: {
permissions: customAccessPolicyPermissions
}
dependsOn: [
redisCacheBuiltInAccessPolicyAssignment
]
}
resource redisCacheCustomAccessPolicyAssignment 'Microsoft.Cache/redis/accessPolicyAssignments@2023-08-01' = {
name: customAccessPolicyAssignmentName
parent: redisCache
properties: {
accessPolicyName: customAccessPolicyName
objectId: customAccessPolicyAssignmentObjectId
objectIdAlias: customAccessPolicyAssignmentObjectAlias
}
dependsOn: [
redisCacheCustomAccessPolicy
]
}
Sumber daya berikut ini ditentukan di file Bicep:
Menyebarkan file Azure Cache for Redis Bicep
Simpan file Bicep sebagai main.bicep ke penyimpanan lokal komputer Anda.
Sebarkan file Bicep menggunakan Azure CLI atau Azure PowerShell.
az deployment group create --resource-group exampleRG --template-file main.bicep --parameters existingDiagnosticsStorageAccountName=<storage-name> existingDiagnosticsStorageAccountResourceGroup=<resource-group>Nota
Ganti <akun penyimpanan-nama> dengan nama akun penyimpanan yang Anda buat di awal mulai cepat ini. Ganti <grup sumber daya> dengan nama grup sumber daya tempat akun penyimpanan Anda berada.
Setelah penyebaran selesai, Anda akan melihat pesan yang menunjukkan sebar berhasil.
Azure Managed Redis
Tinjau ulang file Bicep
@description('Specify the name of the Azure Redis Cache to create.')
param redisCacheName string = 'redisCache-${uniqueString(resourceGroup().id)}'
@description('Location of all resources')
param location string = resourceGroup().location
resource redisEnterprise 'Microsoft.Cache/redisEnterprise@2024-05-01-preview' = {
name: redisCacheName
location: location
sku: {
name: 'Balanced_B5'
}
identity: {
type: 'None'
}
properties: {
minimumTlsVersion: '1.2'
}
}
resource redisEnterpriseDatabase 'Microsoft.Cache/redisEnterprise/databases@2024-05-01-preview' = {
name: 'default'
parent: redisEnterprise
properties:{
clientProtocol: 'Encrypted'
port: 10000
clusteringPolicy: 'OSSCluster'
evictionPolicy: 'NoEviction'
persistence:{
aofEnabled: false
rdbEnabled: false
}
}
}
Sumber daya berikut ini ditentukan di file Bicep:
Menerapkan file Bicep tersebut
Simpan file Bicep sebagai main.bicep ke penyimpanan lokal komputer Anda.
Sebarkan file Bicep menggunakan Azure CLI atau Azure PowerShell.
az deployment group create --resource-group exampleRG --template-file main.bicep
Meninjau sumber daya yang disebarkan
Gunakan portal Microsoft Azure, Azure CLI, atau Azure PowerShell untuk mencantumkan sumber daya yang disebarkan dalam grup sumber daya.
az resource list --resource-group exampleRG
Membersihkan sumber daya
Jika tidak lagi diperlukan, hapus grup sumber daya yang juga akan menghapus sumber daya di grup sumber daya.
az group delete --name exampleRG
Konten terkait
- Pelajari lebih lanjut templat ARM