選項
首頁首頁 Skill 開發營運和 CI/CD azure-resource-manager-redis-dotnet

azure-resource-manager-redis-dotnet

microsoft/skills microsoft/skills

透過 Azure Resource Manager .NET SDK 管理 Azure Cache for Redis 執行個體,包括建立、防火牆規則、存取金鑰、修補程式排程、地理複寫及私有端點。

...展開全部
0
更新時間 2026-09-18

Azure.ResourceManager.Redis (.NET)

用於透過 Azure Resource Manager 配置和管理 Azure Cache for Redis 資源的管理層 SDK。

⚠️ 管理平面與資料平面

  • 此 SDK (Azure.ResourceManager.Redis):建立快取、設定防火牆規則、管理存取金鑰、設定地理複寫
  • 資料平面 SDK (StackExchange.Redis):取得/設定金鑰、發佈/訂閱、串流、Lua 腳本

安裝

dotnet add package Azure.ResourceManager.Redis
dotnet add package Azure.Identity

當前版本:1.5.1(穩定版)
API 版本:2024-11-01
目標框架:.NET 8.0、.NET Standard 2.0

環境變數

AZURE_SUBSCRIPTION_ID= # 必填:Azure 訂閱 ID
AZURE_TOKEN_CREDENTIALS=prod  # 僅當在生產環境中使用 DefaultAzureCredential 時才需填寫
AZURE_TENANT_ID= # 用於服務主體驗證(可選)
AZURE_CLIENT_ID= # 用於服務主體驗證(可選)
AZURE_CLIENT_SECRET= # 用於服務主體驗證(可選)

驗證

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Redis;

// 本地開發環境:DefaultAzureCredential。生產環境:請設定 AZURE_TOKEN_CREDENTIALS=prod 或 AZURE_TOKEN_CREDENTIALS=
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// 或者在生產環境中直接使用特定憑證:
// 參閱 https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
var armClient = new ArmClient(credential);

// 取得訂閱
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
    new ResourceIdentifier($"/subscriptions/{subscriptionId}"));

資源層級結構

ArmClient
└── SubscriptionResource
    └── ResourceGroupResource
        └── RedisResource
            ├── RedisFirewallRuleResource
            ├── RedisPatchScheduleResource
            ├── RedisLinkedServerWithPropertyResource
            ├── RedisPrivateEndpointConnectionResource
            └── RedisCacheAccessPolicyResource

核心工作流程

1. 建立 Redis 快取

using Azure.ResourceManager.Redis;
using Azure.ResourceManager.Redis.Models;

// 取得資源群組
var resourceGroup = await subscription
    .GetResourceGroupAsync("my-resource-group");

// 定義快取設定
var cacheData = new RedisCreateOrUpdateContent(
    location: AzureLocation.EastUS,
    sku: new RedisSku(RedisSkuName.Standard, RedisSkuFamily.BasicOrStandard, 1))
{
    EnableNonSslPort = false,
    MinimumTlsVersion = RedisTlsVersion.Tls1_2,
    RedisConfiguration = new RedisCommonConfiguration
    {
        MaxMemoryPolicy = "volatile-lru"
    },
    Tags =
    {
        ["environment"] = "production"
    }
};

// 建立快取(長期執行操作)
var cacheCollection = resourceGroup.Value.GetAllRedis();
var operation = await cacheCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "my-redis-cache",
    cacheData);

RedisResource cache = operation.Value;
Console.WriteLine($"快取已建立:{cache.Data.HostName}");

2. 取得 Redis 快取

// 取得現有快取
var cache = await resourceGroup.Value
    .GetRedisAsync("my-redis-cache");

Console.WriteLine($"主機名稱:{cache.Value.Data.HostName}");
Console.WriteLine($"埠號:{cache.Value.Data.Port}");
Console.WriteLine($"SSL 埠號:{cache.Value.Data.SslPort}");
Console.WriteLine($"配置狀態:{cache.Value.Data.ProvisioningState}");

3. 更新 Redis 快取

var patchData = new RedisPatch
{
    Sku = new RedisSku(RedisSkuName.Standard, RedisSkuFamily.BasicOrStandard, 2),
    RedisConfiguration = new RedisCommonConfiguration
    {
        MaxMemoryPolicy = "allkeys-lru"
    }
};

var updateOperation = await cache.Value.UpdateAsync(
    WaitUntil.Completed,
    patchData);

4. 刪除 Redis 快取

await cache.Value.DeleteAsync(WaitUntil.Completed);

5. 取得存取金鑰

var keys = await cache.Value.GetKeysAsync();
Console.WriteLine($"主鍵:{keys.Value.PrimaryKey}");
Console.WriteLine($"次鍵:{keys.Value.SecondaryKey}");

6. 重新產生存取金鑰

var regenerateContent = new RedisRegenerateKeyContent(RedisRegenerateKeyType.Primary);
var newKeys = await cache.Value.RegenerateKeyAsync(regenerateContent);
Console.WriteLine($"新主鍵:{newKeys.Value.PrimaryKey}");

7. 管理防火牆規則

// 建立防火牆規則
var firewallData = new RedisFirewallRuleData(
    startIP: System.Net.IPAddress.Parse("10.0.0.1"),
    endIP: System.Net.IPAddress.Parse("10.0.0.255"));

var firewallCollection = cache.Value.GetRedisFirewallRules();
var firewallOperation = await firewallCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "allow-internal-network",
    firewallData);

// 列出所有防火牆規則
await foreach (var rule in firewallCollection.GetAllAsync())
{
    Console.WriteLine($"規則:{rule.Data.Name} ({rule.Data.StartIP} - {rule.Data.EndIP})");
}

// 刪除防火牆規則
var ruleToDelete = await firewallCollection.GetAsync("allow-internal-network");
await ruleToDelete.Value.DeleteAsync(WaitUntil.Completed);

8. 設定修補程式排程(Premium SKU)

// 修補程式排程需使用 Premium SKU
var scheduleData = new RedisPatchScheduleData(
    new[]
    {
        new RedisPatchScheduleSetting(RedisDayOfWeek.Saturday, 2) // 週六凌晨 2 點
        {
            MaintenanceWindow = TimeSpan.FromHours(5)
        },
        new RedisPatchScheduleSetting(RedisDayOfWeek.Saturday, 2) // 週六凌晨 2 點
        {
            MaintenanceWindow = TimeSpan.FromHours(5)
        }
    });

var scheduleCollection = cache.Value.GetRedisPatchSchedules();
await scheduleCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    RedisPatchScheduleDefaultName.Default,
    scheduleData);

9. 資料匯入/匯出(Premium SKU)

// 從 Blob 儲存體匯入資料
var importContent = new ImportRdbContent(
    files: new[] { "https://mystorageaccount.blob.core.windows.net/container/dump.rdb" },
    format: "RDB");

await cache.Value.ImportDataAsync(WaitUntil.Completed, importContent);

// 將資料匯出至 Blob 儲存體
var exportContent = new ExportRdbContent(
    prefix: "backup",
    container: "https://mystorageaccount.blob.core.windows.net/container?sastoken",
    format: "RDB");

await cache.Value.ExportDataAsync(WaitUntil.Completed, exportContent);

10. 強制重新啟動

var rebootContent = new RedisRebootContent
{
    RebootType = RedisRebootType.AllNodes,
    ShardId = 0 // 適用於叢集式快取
};

await cache.Value.ForceRebootAsync(rebootContent);

SKU 參考

SKU 系列 容量 功能
基本款 C 0-6 單一節點,無 SLA,僅限開發/測試
標準 C 0-6 兩個節點(主節點/備份節點),SLA
高級 P 1-5 叢集、地理複製、虛擬網路、資料持久性

容量規格(C 系列 - 基本/標準)

  • C0:250 MB
  • C1:1 GB
  • C2:2.5 GB
  • C3:6 GB
  • C4:13 GB
  • C5:26 GB
  • C6:53 GB

容量規格(P 系列 - 尊享版)

  • P1:每個分片 6 GB
  • P2:每個分片 13 GB
  • P3:每個分片 26 GB
  • P4:每個分片 53 GB
  • P5:每個分片 120 GB

鍵值類型參考

類型 用途
ArmClient 所有 ARM 操作的入口點
RedisResource 代表一個 Redis 快取實例
RedisCollection 用於快取 CRUD 操作的集合
RedisFirewallRuleResource 用於 IP 過濾的防火牆規則
RedisPatchScheduleResource 維護時段設定
RedisLinkedServerWithPropertyResource 地理複製關聯伺服器
RedisPrivateEndpointConnectionResource 私有端點連線
RedisCacheAccessPolicyResource RBAC 存取政策
RedisCreateOrUpdateContent 快取建立資料包
RedisPatch 快取更新載荷
RedisSku SKU 配置(名稱、系列、容量)
RedisAccessKeys 主存取金鑰與次要存取金鑰
RedisRegenerateKeyContent 金鑰重新產生請求

最佳實務

  1. 對於必須在繼續執行前完成的操作,請使用WaitUntil.Completed
  2. 若要手動輪詢或並行執行操作 請使用WaitUntil.Started
  3. 請始終使用DefaultAzureCredential— 切勿將金鑰硬編碼
  4. 針對 ARM API 錯誤處理RequestFailedException
  5. 對於幺正操作,請使用CreateOrUpdateAsync
  6. 透過Get*方法瀏覽層級結構(例如:cache.GetRedisFirewallRules()
  7. 對於需要地理複製、叢集或持久化的生產環境工作負載,請使用 Premium SKU
  8. 啟用至少 TLS 1.2— 設定MinimumTlsVersion = RedisTlsVersion.Tls1_2
  9. 為確保安全性,請停用非 SSL 連接埠— 將EnableNonSslPort 設為 false
  10. 定期輪替金鑰— 使用RegenerateKeyAsync並更新連線字串

錯誤處理

using Azure;

try
{
    var operation = await cacheCollection.CreateOrUpdateAsync(
        WaitUntil.Completed, cacheName, cacheData);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
    Console.WriteLine("快取已存在");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
    Console.WriteLine($"配置無效:{ex.Message}");
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"ARM 錯誤:{ex.Status} - {ex.ErrorCode}:{ex.Message}");
}

常見陷阱

  1. 不允許降級 SKU— 無法從 Premium 降級至 Standard/Basic
  2. 叢集功能需 Premium 版本— 分片配置僅在 Premium SKU 上可用
  3. 地理複製需 Premium版本 — 連結伺服器僅適用於 Premium 快取
  4. 虛擬網路注入需 Premium 版本— 虛擬網路支援僅限 Premium 版本
  5. 修補程式排程需 Premium 版本— 維護時段僅可在 Premium 版本上進行設定
  6. 快取名稱須為全局唯一— Redis 快取名稱在所有 Azure 訂閱中必須唯一
  7. 配置時間較長— 建立快取可能需要 15 至 20 分鐘;若採用非同步模式,請使用WaitUntil.Started

透過 StackExchange.Redis 建立連線(資料平面)

使用此管理 SDK 建立快取後,請使用 StackExchange.Redis 進行資料操作:

using StackExchange.Redis;

// 從管理 SDK 取得連線資訊
var cache = await resourceGroup.Value.GetRedisAsync("my-redis-cache");
var keys = await cache.Value.GetKeysAsync();

// 透過 StackExchange.Redis 建立連線
var connectionString = $"{cache.Value.Data.HostName}:{cache.Value.Data.SslPort},password={keys.Value.PrimaryKey},ssl=True,abortConnect=False";
var connection = ConnectionMultiplexer.Connect(connectionString);
var db = connection.GetDatabase();

// 資料操作
await db.StringSetAsync("key", "value");
var value = await db.StringGetAsync("key");

相關 SDK

SDK 用途 安裝
StackExchange.Redis 資料層(get/set、pub/sub、串流) dotnet add package StackExchange.Redis
Azure.ResourceManager.Redis 管理層 (此 SDK) dotnet add package Azure.ResourceManager.Redis
Microsoft.Azure.StackExchangeRedis Azure 專屬的 Redis 擴充功能 dotnet add package Microsoft.Azure.StackExchangeRedis
在 GitHub 上查看
---
name: azure-resource-manager-redis-dotnet
description: Manage Azure Cache for Redis instances via the Azure Resource Manager .NET SDK, including creation, firewall rules, access keys, patch schedules, geo-replication, and private endpoints.
license: MIT
---

# Azure.ResourceManager.Redis (.NET)

Management plane SDK for provisioning and managing Azure Cache for Redis resources via Azure Resource Manager.

> **⚠️ Management vs Data Plane**
> - **This SDK (Azure.ResourceManager.Redis)**: Create caches, configure firewall rules, manage access keys, set up geo-replication
> - **Data Plane SDK (StackExchange.Redis)**: Get/set keys, pub/sub, streams, Lua scripts

## Installation

```bash
dotnet add package Azure.ResourceManager.Redis
dotnet add package Azure.Identity
```

**Current Version**: 1.5.1 (Stable)  
**API Version**: 2024-11-01  
**Target Frameworks**: .NET 8.0, .NET Standard 2.0

## Environment Variables

```bash
AZURE_SUBSCRIPTION_ID=<your-subscription-id>  # Required: Azure subscription ID
AZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production
AZURE_TENANT_ID=<tenant-id>  # For service principal auth (optional)
AZURE_CLIENT_ID=<client-id>  # For service principal auth (optional)
AZURE_CLIENT_SECRET=<client-secret>  # For service principal auth (optional)
```

## Authentication

```csharp
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Redis;

// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
var armClient = new ArmClient(credential);

// Get subscription
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
    new ResourceIdentifier($"/subscriptions/{subscriptionId}"));
```

## Resource Hierarchy

```
ArmClient
└── SubscriptionResource
    └── ResourceGroupResource
        └── RedisResource
            ├── RedisFirewallRuleResource
            ├── RedisPatchScheduleResource
            ├── RedisLinkedServerWithPropertyResource
            ├── RedisPrivateEndpointConnectionResource
            └── RedisCacheAccessPolicyResource
```

## Core Workflows

### 1. Create Redis Cache

```csharp
using Azure.ResourceManager.Redis;
using Azure.ResourceManager.Redis.Models;

// Get resource group
var resourceGroup = await subscription
    .GetResourceGroupAsync("my-resource-group");

// Define cache configuration
var cacheData = new RedisCreateOrUpdateContent(
    location: AzureLocation.EastUS,
    sku: new RedisSku(RedisSkuName.Standard, RedisSkuFamily.BasicOrStandard, 1))
{
    EnableNonSslPort = false,
    MinimumTlsVersion = RedisTlsVersion.Tls1_2,
    RedisConfiguration = new RedisCommonConfiguration
    {
        MaxMemoryPolicy = "volatile-lru"
    },
    Tags =
    {
        ["environment"] = "production"
    }
};

// Create cache (long-running operation)
var cacheCollection = resourceGroup.Value.GetAllRedis();
var operation = await cacheCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "my-redis-cache",
    cacheData);

RedisResource cache = operation.Value;
Console.WriteLine($"Cache created: {cache.Data.HostName}");
```

### 2. Get Redis Cache

```csharp
// Get existing cache
var cache = await resourceGroup.Value
    .GetRedisAsync("my-redis-cache");

Console.WriteLine($"Host: {cache.Value.Data.HostName}");
Console.WriteLine($"Port: {cache.Value.Data.Port}");
Console.WriteLine($"SSL Port: {cache.Value.Data.SslPort}");
Console.WriteLine($"Provisioning State: {cache.Value.Data.ProvisioningState}");
```

### 3. Update Redis Cache

```csharp
var patchData = new RedisPatch
{
    Sku = new RedisSku(RedisSkuName.Standard, RedisSkuFamily.BasicOrStandard, 2),
    RedisConfiguration = new RedisCommonConfiguration
    {
        MaxMemoryPolicy = "allkeys-lru"
    }
};

var updateOperation = await cache.Value.UpdateAsync(
    WaitUntil.Completed,
    patchData);
```

### 4. Delete Redis Cache

```csharp
await cache.Value.DeleteAsync(WaitUntil.Completed);
```

### 5. Get Access Keys

```csharp
var keys = await cache.Value.GetKeysAsync();
Console.WriteLine($"Primary Key: {keys.Value.PrimaryKey}");
Console.WriteLine($"Secondary Key: {keys.Value.SecondaryKey}");
```

### 6. Regenerate Access Keys

```csharp
var regenerateContent = new RedisRegenerateKeyContent(RedisRegenerateKeyType.Primary);
var newKeys = await cache.Value.RegenerateKeyAsync(regenerateContent);
Console.WriteLine($"New Primary Key: {newKeys.Value.PrimaryKey}");
```

### 7. Manage Firewall Rules

```csharp
// Create firewall rule
var firewallData = new RedisFirewallRuleData(
    startIP: System.Net.IPAddress.Parse("10.0.0.1"),
    endIP: System.Net.IPAddress.Parse("10.0.0.255"));

var firewallCollection = cache.Value.GetRedisFirewallRules();
var firewallOperation = await firewallCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "allow-internal-network",
    firewallData);

// List all firewall rules
await foreach (var rule in firewallCollection.GetAllAsync())
{
    Console.WriteLine($"Rule: {rule.Data.Name} ({rule.Data.StartIP} - {rule.Data.EndIP})");
}

// Delete firewall rule
var ruleToDelete = await firewallCollection.GetAsync("allow-internal-network");
await ruleToDelete.Value.DeleteAsync(WaitUntil.Completed);
```

### 8. Configure Patch Schedule (Premium SKU)

```csharp
// Patch schedules require Premium SKU
var scheduleData = new RedisPatchScheduleData(
    new[]
    {
        new RedisPatchScheduleSetting(RedisDayOfWeek.Saturday, 2) // 2 AM Saturday
        {
            MaintenanceWindow = TimeSpan.FromHours(5)
        },
        new RedisPatchScheduleSetting(RedisDayOfWeek.Sunday, 2) // 2 AM Sunday
        {
            MaintenanceWindow = TimeSpan.FromHours(5)
        }
    });

var scheduleCollection = cache.Value.GetRedisPatchSchedules();
await scheduleCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    RedisPatchScheduleDefaultName.Default,
    scheduleData);
```

### 9. Import/Export Data (Premium SKU)

```csharp
// Import data from blob storage
var importContent = new ImportRdbContent(
    files: new[] { "https://mystorageaccount.blob.core.windows.net/container/dump.rdb" },
    format: "RDB");

await cache.Value.ImportDataAsync(WaitUntil.Completed, importContent);

// Export data to blob storage
var exportContent = new ExportRdbContent(
    prefix: "backup",
    container: "https://mystorageaccount.blob.core.windows.net/container?sastoken",
    format: "RDB");

await cache.Value.ExportDataAsync(WaitUntil.Completed, exportContent);
```

### 10. Force Reboot

```csharp
var rebootContent = new RedisRebootContent
{
    RebootType = RedisRebootType.AllNodes,
    ShardId = 0 // For clustered caches
};

await cache.Value.ForceRebootAsync(rebootContent);
```

## SKU Reference

| SKU | Family | Capacity | Features |
|-----|--------|----------|----------|
| Basic | C | 0-6 | Single node, no SLA, dev/test only |
| Standard | C | 0-6 | Two nodes (primary/replica), SLA |
| Premium | P | 1-5 | Clustering, geo-replication, VNet, persistence |

**Capacity Sizes (Family C - Basic/Standard)**:
- C0: 250 MB
- C1: 1 GB
- C2: 2.5 GB
- C3: 6 GB
- C4: 13 GB
- C5: 26 GB
- C6: 53 GB

**Capacity Sizes (Family P - Premium)**:
- P1: 6 GB per shard
- P2: 13 GB per shard
- P3: 26 GB per shard
- P4: 53 GB per shard
- P5: 120 GB per shard

## Key Types Reference

| Type | Purpose |
|------|---------|
| `ArmClient` | Entry point for all ARM operations |
| `RedisResource` | Represents a Redis cache instance |
| `RedisCollection` | Collection for cache CRUD operations |
| `RedisFirewallRuleResource` | Firewall rule for IP filtering |
| `RedisPatchScheduleResource` | Maintenance window configuration |
| `RedisLinkedServerWithPropertyResource` | Geo-replication linked server |
| `RedisPrivateEndpointConnectionResource` | Private endpoint connection |
| `RedisCacheAccessPolicyResource` | RBAC access policy |
| `RedisCreateOrUpdateContent` | Cache creation payload |
| `RedisPatch` | Cache update payload |
| `RedisSku` | SKU configuration (name, family, capacity) |
| `RedisAccessKeys` | Primary and secondary access keys |
| `RedisRegenerateKeyContent` | Key regeneration request |

## Best Practices

1. **Use `WaitUntil.Completed`** for operations that must finish before proceeding
2. **Use `WaitUntil.Started`** when you want to poll manually or run operations in parallel
3. **Always use `DefaultAzureCredential`** — never hardcode keys
4. **Handle `RequestFailedException`** for ARM API errors
5. **Use `CreateOrUpdateAsync`** for idempotent operations
6. **Navigate hierarchy** via `Get*` methods (e.g., `cache.GetRedisFirewallRules()`)
7. **Use Premium SKU** for production workloads requiring geo-replication, clustering, or persistence
8. **Enable TLS 1.2 minimum** — set `MinimumTlsVersion = RedisTlsVersion.Tls1_2`
9. **Disable non-SSL port** — set `EnableNonSslPort = false` for security
10. **Rotate keys regularly** — use `RegenerateKeyAsync` and update connection strings

## Error Handling

```csharp
using Azure;

try
{
    var operation = await cacheCollection.CreateOrUpdateAsync(
        WaitUntil.Completed, cacheName, cacheData);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
    Console.WriteLine("Cache already exists");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
    Console.WriteLine($"Invalid configuration: {ex.Message}");
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");
}
```

## Common Pitfalls

1. **SKU downgrades not allowed** — You cannot downgrade from Premium to Standard/Basic
2. **Clustering requires Premium** — Shard configuration only available on Premium SKU
3. **Geo-replication requires Premium** — Linked servers only work with Premium caches
4. **VNet injection requires Premium** — Virtual network support is Premium-only
5. **Patch schedules require Premium** — Maintenance windows only configurable on Premium
6. **Cache name globally unique** — Redis cache names must be unique across all Azure subscriptions
7. **Long provisioning times** — Cache creation can take 15-20 minutes; use `WaitUntil.Started` for async patterns

## Connecting with StackExchange.Redis (Data Plane)

After creating the cache with this management SDK, use StackExchange.Redis for data operations:

```csharp
using StackExchange.Redis;

// Get connection info from management SDK
var cache = await resourceGroup.Value.GetRedisAsync("my-redis-cache");
var keys = await cache.Value.GetKeysAsync();

// Connect with StackExchange.Redis
var connectionString = $"{cache.Value.Data.HostName}:{cache.Value.Data.SslPort},password={keys.Value.PrimaryKey},ssl=True,abortConnect=False";
var connection = ConnectionMultiplexer.Connect(connectionString);
var db = connection.GetDatabase();

// Data operations
await db.StringSetAsync("key", "value");
var value = await db.StringGetAsync("key");
```

## Related SDKs

| SDK | Purpose | Install |
|-----|---------|---------|
| `StackExchange.Redis` | Data plane (get/set, pub/sub, streams) | `dotnet add package StackExchange.Redis` |
| `Azure.ResourceManager.Redis` | Management plane (this SDK) | `dotnet add package Azure.ResourceManager.Redis` |
| `Microsoft.Azure.StackExchangeRedis` | Azure-specific Redis extensions | `dotnet add package Microsoft.Azure.StackExchangeRedis` |

所有檔案

0 個檔案

安裝 azure-resource-manager-redis-dotnet

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-resource-manager-redis-dotnet # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/ Claude 會自動偵測並使用該技能
儲存庫 microsoft/skills

相關技能

Verification &amp; Quality Assurance
更新時間 2026-06-29
klingai-upgrade-migration
更新時間 2026-07-03
base44-cli
更新時間 2026-06-29
Railway CLI Management
更新時間 2026-07-02
OR