选项
首页首页 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. 数据导入/导出(高级 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 维护时段配置
Redis带属性的关联服务器资源 地理复制关联服务器
Redis私有端点连接资源 私有端点连接
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— 无法从“高级”降级至“标准”或“基础”
  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 会自动检测并使用该技能

相关技能

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