{"slug":"azure-resource-manager-redis-dotnet","title":"azure-resource-manager-redis-dotnet","summary":"Azure Resource Manager SDK for Redis in .NET. Use for MANAGEMENT PLANE operations: creating/managing Azure Cache for Redis instances, firewall rules, access keys, patch schedules, linked servers (geo-replication), and private endpoints via Azure Resource Manager. NOT for data pla","platform":"GitHub Copilot","tags":[],"authorName":"Ciza","authorSlug":"ciza","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-12T21:05:14.669324Z","repo":{"url":"https://github.com/microsoft/skills","stars":3226,"forks":373,"license":"MIT","updatedAt":"2026-11-19T11:04:16Z"},"bodyHtml":"<hr>\n<h2>name: azure-resource-manager-redis-dotnet\ndescription: |\nAzure Resource Manager SDK for Redis in .NET. Use for MANAGEMENT PLANE operations: creating/managing Azure Cache for Redis instances, firewall rules, access keys, patch schedules, linked servers (geo-replication), and private endpoints via Azure Resource Manager. NOT for data plane operations (get/set keys, pub/sub) - use StackExchange.Redis for that. Triggers: \"Redis cache\", \"create Redis\", \"manage Redis\", \"ARM Redis\", \"RedisResource\", \"provision Redis\", \"Azure Cache for Redis\".\nlicense: MIT\nmetadata:\nauthor: Microsoft\nversion: \"1.0.0\"\npackage: Azure.ResourceManager.Redis</h2>\n<h1>Azure.ResourceManager.Redis (.NET)</h1>\n<p>Management plane SDK for provisioning and managing Azure Cache for Redis resources via Azure Resource Manager.</p>\n<blockquote>\n<p><strong>⚠️ Management vs Data Plane</strong></p>\n<ul>\n<li><strong>This SDK (Azure.ResourceManager.Redis)</strong>: Create caches, configure firewall rules, manage access keys, set up geo-replication</li>\n<li><strong>Data Plane SDK (StackExchange.Redis)</strong>: Get/set keys, pub/sub, streams, Lua scripts</li>\n</ul>\n</blockquote>\n<h2>Installation</h2>\n<pre><code>dotnet add package Azure.ResourceManager.Redis\ndotnet add package Azure.Identity\n</code></pre>\n<p><strong>Current Version</strong>: 1.5.1 (Stable)<br>\n<strong>API Version</strong>: 2024-11-01<br>\n<strong>Target Frameworks</strong>: .NET 8.0, .NET Standard 2.0</p>\n<h2>Environment Variables</h2>\n<pre><code>AZURE_SUBSCRIPTION_ID=&lt;your-subscription-id&gt;  # Required: Azure subscription ID\nAZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production\nAZURE_TENANT_ID=&lt;tenant-id&gt;  # For service principal auth (optional)\nAZURE_CLIENT_ID=&lt;client-id&gt;  # For service principal auth (optional)\nAZURE_CLIENT_SECRET=&lt;client-secret&gt;  # For service principal auth (optional)\n</code></pre>\n<h2>Authentication</h2>\n<pre><code>using Azure.Identity;\nusing Azure.ResourceManager;\nusing Azure.ResourceManager.Redis;\n\n// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=&lt;specific_credential&gt;\nvar credential = new DefaultAzureCredential(\n    DefaultAzureCredential.DefaultEnvironmentVariableName\n);\n// Or use a specific credential directly in production:\n// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes\n// var credential = new ManagedIdentityCredential();\nvar armClient = new ArmClient(credential);\n\n// Get subscription\nvar subscriptionId = Environment.GetEnvironmentVariable(\"AZURE_SUBSCRIPTION_ID\");\nvar subscription = armClient.GetSubscriptionResource(\n    new ResourceIdentifier($\"/subscriptions/{subscriptionId}\"));\n</code></pre>\n<h2>Resource Hierarchy</h2>\n<pre><code>ArmClient\n└── SubscriptionResource\n    └── ResourceGroupResource\n        └── RedisResource\n            ├── RedisFirewallRuleResource\n            ├── RedisPatchScheduleResource\n            ├── RedisLinkedServerWithPropertyResource\n            ├── RedisPrivateEndpointConnectionResource\n            └── RedisCacheAccessPolicyResource\n</code></pre>\n<h2>Core Workflows</h2>\n<h3>1. Create Redis Cache</h3>\n<pre><code>using Azure.ResourceManager.Redis;\nusing Azure.ResourceManager.Redis.Models;\n\n// Get resource group\nvar resourceGroup = await subscription\n    .GetResourceGroupAsync(\"my-resource-group\");\n\n// Define cache configuration\nvar cacheData = new RedisCreateOrUpdateContent(\n    location: AzureLocation.EastUS,\n    sku: new RedisSku(RedisSkuName.Standard, RedisSkuFamily.BasicOrStandard, 1))\n{\n    EnableNonSslPort = false,\n    MinimumTlsVersion = RedisTlsVersion.Tls1_2,\n    RedisConfiguration = new RedisCommonConfiguration\n    {\n        MaxMemoryPolicy = \"volatile-lru\"\n    },\n    Tags =\n    {\n        [\"environment\"] = \"production\"\n    }\n};\n\n// Create cache (long-running operation)\nvar cacheCollection = resourceGroup.Value.GetAllRedis();\nvar operation = await cacheCollection.CreateOrUpdateAsync(\n    WaitUntil.Completed,\n    \"my-redis-cache\",\n    cacheData);\n\nRedisResource cache = operation.Value;\nConsole.WriteLine($\"Cache created: {cache.Data.HostName}\");\n</code></pre>\n<h3>2. Get Redis Cache</h3>\n<pre><code>// Get existing cache\nvar cache = await resourceGroup.Value\n    .GetRedisAsync(\"my-redis-cache\");\n\nConsole.WriteLine($\"Host: {cache.Value.Data.HostName}\");\nConsole.WriteLine($\"Port: {cache.Value.Data.Port}\");\nConsole.WriteLine($\"SSL Port: {cache.Value.Data.SslPort}\");\nConsole.WriteLine($\"Provisioning State: {cache.Value.Data.ProvisioningState}\");\n</code></pre>\n<h3>3. Update Redis Cache</h3>\n<pre><code>var patchData = new RedisPatch\n{\n    Sku = new RedisSku(RedisSkuName.Standard, RedisSkuFamily.BasicOrStandard, 2),\n    RedisConfiguration = new RedisCommonConfiguration\n    {\n        MaxMemoryPolicy = \"allkeys-lru\"\n    }\n};\n\nvar updateOperation = await cache.Value.UpdateAsync(\n    WaitUntil.Completed,\n    patchData);\n</code></pre>\n<h3>4. Delete Redis Cache</h3>\n<pre><code>await cache.Value.DeleteAsync(WaitUntil.Completed);\n</code></pre>\n<h3>5. Get Access Keys</h3>\n<pre><code>var keys = await cache.Value.GetKeysAsync();\nConsole.WriteLine($\"Primary Key: {keys.Value.PrimaryKey}\");\nConsole.WriteLine($\"Secondary Key: {keys.Value.SecondaryKey}\");\n</code></pre>\n<h3>6. Regenerate Access Keys</h3>\n<pre><code>var regenerateContent = new RedisRegenerateKeyContent(RedisRegenerateKeyType.Primary);\nvar newKeys = await cache.Value.RegenerateKeyAsync(regenerateContent);\nConsole.WriteLine($\"New Primary Key: {newKeys.Value.PrimaryKey}\");\n</code></pre>\n<h3>7. Manage Firewall Rules</h3>\n<pre><code>// Create firewall rule\nvar firewallData = new RedisFirewallRuleData(\n    startIP: System.Net.IPAddress.Parse(\"10.0.0.1\"),\n    endIP: System.Net.IPAddress.Parse(\"10.0.0.255\"));\n\nvar firewallCollection = cache.Value.GetRedisFirewallRules();\nvar firewallOperation = await firewallCollection.CreateOrUpdateAsync(\n    WaitUntil.Completed,\n    \"allow-internal-network\",\n    firewallData);\n\n// List all firewall rules\nawait foreach (var rule in firewallCollection.GetAllAsync())\n{\n    Console.WriteLine($\"Rule: {rule.Data.Name} ({rule.Data.StartIP} - {rule.Data.EndIP})\");\n}\n\n// Delete firewall rule\nvar ruleToDelete = await firewallCollection.GetAsync(\"allow-internal-network\");\nawait ruleToDelete.Value.DeleteAsync(WaitUntil.Completed);\n</code></pre>\n<h3>8. Configure Patch Schedule (Premium SKU)</h3>\n<pre><code>// Patch schedules require Premium SKU\nvar scheduleData = new RedisPatchScheduleData(\n    new[]\n    {\n        new RedisPatchScheduleSetting(RedisDayOfWeek.Saturday, 2) // 2 AM Saturday\n        {\n            MaintenanceWindow = TimeSpan.FromHours(5)\n        },\n        new RedisPatchScheduleSetting(RedisDayOfWeek.Sunday, 2) // 2 AM Sunday\n        {\n            MaintenanceWindow = TimeSpan.FromHours(5)\n        }\n    });\n\nvar scheduleCollection = cache.Value.GetRedisPatchSchedules();\nawait scheduleCollection.CreateOrUpdateAsync(\n    WaitUntil.Completed,\n    RedisPatchScheduleDefaultName.Default,\n    scheduleData);\n</code></pre>\n<h3>9. Import/Export Data (Premium SKU)</h3>\n<pre><code>// Import data from blob storage\nvar importContent = new ImportRdbContent(\n    files: new[] { \"https://mystorageaccount.blob.core.windows.net/container/dump.rdb\" },\n    format: \"RDB\");\n\nawait cache.Value.ImportDataAsync(WaitUntil.Completed, importContent);\n\n// Export data to blob storage\nvar exportContent = new ExportRdbContent(\n    prefix: \"backup\",\n    container: \"https://mystorageaccount.blob.core.windows.net/container?sastoken\",\n    format: \"RDB\");\n\nawait cache.Value.ExportDataAsync(WaitUntil.Completed, exportContent);\n</code></pre>\n<h3>10. Force Reboot</h3>\n<pre><code>var rebootContent = new RedisRebootContent\n{\n    RebootType = RedisRebootType.AllNodes,\n    ShardId = 0 // For clustered caches\n};\n\nawait cache.Value.ForceRebootAsync(rebootContent);\n</code></pre>\n<h2>SKU Reference</h2>\n<table>\n<thead>\n<tr>\n<th>SKU</th>\n<th>Family</th>\n<th>Capacity</th>\n<th>Features</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Basic</td>\n<td>C</td>\n<td>0-6</td>\n<td>Single node, no SLA, dev/test only</td>\n</tr>\n<tr>\n<td>Standard</td>\n<td>C</td>\n<td>0-6</td>\n<td>Two nodes (primary/replica), SLA</td>\n</tr>\n<tr>\n<td>Premium</td>\n<td>P</td>\n<td>1-5</td>\n<td>Clustering, geo-replication, VNet, persistence</td>\n</tr>\n</tbody>\n</table>\n<p><strong>Capacity Sizes (Family C - Basic/Standard)</strong>:</p>\n<ul>\n<li>C0: 250 MB</li>\n<li>C1: 1 GB</li>\n<li>C2: 2.5 GB</li>\n<li>C3: 6 GB</li>\n<li>C4: 13 GB</li>\n<li>C5: 26 GB</li>\n<li>C6: 53 GB</li>\n</ul>\n<p><strong>Capacity Sizes (Family P - Premium)</strong>:</p>\n<ul>\n<li>P1: 6 GB per shard</li>\n<li>P2: 13 GB per shard</li>\n<li>P3: 26 GB per shard</li>\n<li>P4: 53 GB per shard</li>\n<li>P5: 120 GB per shard</li>\n</ul>\n<h2>Key Types Reference</h2>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>ArmClient</code></td>\n<td>Entry point for all ARM operations</td>\n</tr>\n<tr>\n<td><code>RedisResource</code></td>\n<td>Represents a Redis cache instance</td>\n</tr>\n<tr>\n<td><code>RedisCollection</code></td>\n<td>Collection for cache CRUD operations</td>\n</tr>\n<tr>\n<td><code>RedisFirewallRuleResource</code></td>\n<td>Firewall rule for IP filtering</td>\n</tr>\n<tr>\n<td><code>RedisPatchScheduleResource</code></td>\n<td>Maintenance window configuration</td>\n</tr>\n<tr>\n<td><code>RedisLinkedServerWithPropertyResource</code></td>\n<td>Geo-replication linked server</td>\n</tr>\n<tr>\n<td><code>RedisPrivateEndpointConnectionResource</code></td>\n<td>Private endpoint connection</td>\n</tr>\n<tr>\n<td><code>RedisCacheAccessPolicyResource</code></td>\n<td>RBAC access policy</td>\n</tr>\n<tr>\n<td><code>RedisCreateOrUpdateContent</code></td>\n<td>Cache creation payload</td>\n</tr>\n<tr>\n<td><code>RedisPatch</code></td>\n<td>Cache update payload</td>\n</tr>\n<tr>\n<td><code>RedisSku</code></td>\n<td>SKU configuration (name, family, capacity)</td>\n</tr>\n<tr>\n<td><code>RedisAccessKeys</code></td>\n<td>Primary and secondary access keys</td>\n</tr>\n<tr>\n<td><code>RedisRegenerateKeyContent</code></td>\n<td>Key regeneration request</td>\n</tr>\n</tbody>\n</table>\n<h2>Best Practices</h2>\n<ol>\n<li><strong>Use <code>WaitUntil.Completed</code></strong> for operations that must finish before proceeding</li>\n<li><strong>Use <code>WaitUntil.Started</code></strong> when you want to poll manually or run operations in parallel</li>\n<li><strong>Always use <code>DefaultAzureCredential</code></strong> — never hardcode keys</li>\n<li><strong>Handle <code>RequestFailedException</code></strong> for ARM API errors</li>\n<li><strong>Use <code>CreateOrUpdateAsync</code></strong> for idempotent operations</li>\n<li><strong>Navigate hierarchy</strong> via <code>Get*</code> methods (e.g., <code>cache.GetRedisFirewallRules()</code>)</li>\n<li><strong>Use Premium SKU</strong> for production workloads requiring geo-replication, clustering, or persistence</li>\n<li><strong>Enable TLS 1.2 minimum</strong> — set <code>MinimumTlsVersion = RedisTlsVersion.Tls1_2</code></li>\n<li><strong>Disable non-SSL port</strong> — set <code>EnableNonSslPort = false</code> for security</li>\n<li><strong>Rotate keys regularly</strong> — use <code>RegenerateKeyAsync</code> and update connection strings</li>\n</ol>\n<h2>Error Handling</h2>\n<pre><code>using Azure;\n\ntry\n{\n    var operation = await cacheCollection.CreateOrUpdateAsync(\n        WaitUntil.Completed, cacheName, cacheData);\n}\ncatch (RequestFailedException ex) when (ex.Status == 409)\n{\n    Console.WriteLine(\"Cache already exists\");\n}\ncatch (RequestFailedException ex) when (ex.Status == 400)\n{\n    Console.WriteLine($\"Invalid configuration: {ex.Message}\");\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}\");\n}\n</code></pre>\n<h2>Common Pitfalls</h2>\n<ol>\n<li><strong>SKU downgrades not allowed</strong> — You cannot downgrade from Premium to Standard/Basic</li>\n<li><strong>Clustering requires Premium</strong> — Shard configuration only available on Premium SKU</li>\n<li><strong>Geo-replication requires Premium</strong> — Linked servers only work with Premium caches</li>\n<li><strong>VNet injection requires Premium</strong> — Virtual network support is Premium-only</li>\n<li><strong>Patch schedules require Premium</strong> — Maintenance windows only configurable on Premium</li>\n<li><strong>Cache name globally unique</strong> — Redis cache names must be unique across all Azure subscriptions</li>\n<li><strong>Long provisioning times</strong> — Cache creation can take 15-20 minutes; use <code>WaitUntil.Started</code> for async patterns</li>\n</ol>\n<h2>Connecting with StackExchange.Redis (Data Plane)</h2>\n<p>After creating the cache with this management SDK, use StackExchange.Redis for data operations:</p>\n<pre><code>using StackExchange.Redis;\n\n// Get connection info from management SDK\nvar cache = await resourceGroup.Value.GetRedisAsync(\"my-redis-cache\");\nvar keys = await cache.Value.GetKeysAsync();\n\n// Connect with StackExchange.Redis\nvar connectionString = $\"{cache.Value.Data.HostName}:{cache.Value.Data.SslPort},password={keys.Value.PrimaryKey},ssl=True,abortConnect=False\";\nvar connection = ConnectionMultiplexer.Connect(connectionString);\nvar db = connection.GetDatabase();\n\n// Data operations\nawait db.StringSetAsync(\"key\", \"value\");\nvar value = await db.StringGetAsync(\"key\");\n</code></pre>\n<h2>Related SDKs</h2>\n<table>\n<thead>\n<tr>\n<th>SDK</th>\n<th>Purpose</th>\n<th>Install</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>StackExchange.Redis</code></td>\n<td>Data plane (get/set, pub/sub, streams)</td>\n<td><code>dotnet add package StackExchange.Redis</code></td>\n</tr>\n<tr>\n<td><code>Azure.ResourceManager.Redis</code></td>\n<td>Management plane (this SDK)</td>\n<td><code>dotnet add package Azure.ResourceManager.Redis</code></td>\n</tr>\n<tr>\n<td><code>Microsoft.Azure.StackExchangeRedis</code></td>\n<td>Azure-specific Redis extensions</td>\n<td><code>dotnet add package Microsoft.Azure.StackExchangeRedis</code></td>\n</tr>\n</tbody>\n</table>\n","files":[{"path":"SKILL.md","sizeBytes":12195,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-12T21:51:11.373081Z","sha256":"9EF4284F97E7122D150FB8A97DE5F9367F1BE170837C053C3DE1B0F6FCD60B54","sizeBytes":4172},"review":null,"source":{"repositoryUrl":"https://github.com/microsoft/skills","path":".github/plugins/azure-sdk-dotnet/skills/azure-resource-manager-redis-dotnet","license":"MIT","commit":"b35d2c60fac796bfd2cfd14ad3f550c73e92d9bb","subtreeSha":"ACF831C820D45404481991F971AEDE22D6918AE71A7F2D947F33A7DC7ABE1679","lastSyncedAt":"2026-11-19T20:53:05.968523Z"},"reviewedAt":"2026-08-12T21:55:41.62291Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-resource-manager-redis-dotnet"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install microsoft-skills@llmmart"},{"target":"git","command":"git clone https://github.com/microsoft/skills.git"}]}