From 1ab0cd8d07cc3fa01308d1fe304a038899e80d46 Mon Sep 17 00:00:00 2001 From: Philo Date: Mon, 4 May 2026 17:15:49 -0700 Subject: [PATCH 1/2] Recognize Azure Managed Redis in new clouds --- .../AzureManagedRedisOptionsProvider.cs | 2 ++ .../StackExchange.Redis.Tests/ConfigTests.cs | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/StackExchange.Redis/Configuration/AzureManagedRedisOptionsProvider.cs b/src/StackExchange.Redis/Configuration/AzureManagedRedisOptionsProvider.cs index 06656b608..cdb55ef2d 100644 --- a/src/StackExchange.Redis/Configuration/AzureManagedRedisOptionsProvider.cs +++ b/src/StackExchange.Redis/Configuration/AzureManagedRedisOptionsProvider.cs @@ -25,6 +25,8 @@ public class AzureManagedRedisOptionsProvider : DefaultOptionsProvider ".redis.azure.net", ".redis.chinacloudapi.cn", ".redis.usgovcloudapi.net", + ".redis.sovcloud-api.de", + ".redis.sovcloud-api.fr", ".redisenterprise.cache.azure.net", ]; diff --git a/tests/StackExchange.Redis.Tests/ConfigTests.cs b/tests/StackExchange.Redis.Tests/ConfigTests.cs index 6626eda42..a0ec70ae1 100644 --- a/tests/StackExchange.Redis.Tests/ConfigTests.cs +++ b/tests/StackExchange.Redis.Tests/ConfigTests.cs @@ -135,6 +135,9 @@ public void SslProtocols_InvalidValue() [InlineData("contoso.redis.cache.usgovcloudapi.net:6380", true)] [InlineData("contoso.redis.cache.sovcloud-api.de:6380", true)] [InlineData("contoso.redis.cache.sovcloud-api.fr:6380", true)] + [InlineData("contoso.redis.cache.windows.net:6379", false)] // non-SSL port + [InlineData("contoso.redis.cache.windows.net:10000", false)] // wrong port + [InlineData("contoso.redis.cache.windows.net", false)] // no port public void ConfigurationOptionsDefaultForAzure(string hostAndPort, bool sslShouldBeEnabled) { Version defaultAzureVersion = new(6, 0, 0); @@ -149,11 +152,16 @@ public void ConfigurationOptionsDefaultForAzure(string hostAndPort, bool sslShou [InlineData("contoso.redis.chinacloudapi.cn:10000", true)] [InlineData("contoso.redis.usgovcloudapi.net:10000", true)] [InlineData("contoso.redisenterprise.cache.azure.net:10000", true)] + [InlineData("contoso.REDIS.sovcloud-api.de:10000", true)] // added a few upper case chars to validate comparison + [InlineData("contoso.redis.sovcloud-api.fr:10000", true)] + [InlineData("contoso.redis.azure.net:6379", true)] // AMR port is usually 10000, assume SSL regardless + [InlineData("contoso.redis.azure.net:6380", true)] // AMR port is usually 10000, assume SSL regardless + [InlineData("contoso.redis.azure.net", true)] // no port, assume SSL public void ConfigurationOptionsDefaultForAzureManagedRedis(string hostAndPort, bool sslShouldBeEnabled) { - Version defaultAzureVersion = new(7, 4, 0); + Version defaultAzureManagedRedisVersion = new(7, 4, 0); var options = ConfigurationOptions.Parse(hostAndPort); - Assert.True(options.DefaultVersion.Equals(defaultAzureVersion)); + Assert.True(options.DefaultVersion.Equals(defaultAzureManagedRedisVersion)); Assert.False(options.AbortOnConnectFail); Assert.Equal(sslShouldBeEnabled, options.Ssl); } @@ -166,12 +174,26 @@ public void ConfigurationOptionsForAzureWhenSpecified() Assert.True(options.AbortOnConnectFail); } - [Fact] - public void ConfigurationOptionsDefaultForNonAzure() + [Theory] + [InlineData("redis.contoso.com")] // no port + [InlineData("redis.contoso.com:xx")] // invalid port + [InlineData("redis.contoso.com:6379")] // valid port + [InlineData("contoso.Xredis.cache.windows.net:6380")] // almost an Azure Cache for Redis host name + [InlineData("contoso.redis.cache.windows.netX:6380")] // almost an Azure Cache for Redis host name + [InlineData("contoso.redis.cache.windows.net.X:6380")] // almost an Azure Cache for Redis host name + [InlineData("contoso.Xredis.azure.net:10000")] // almost an Azure Managed Redis host name + [InlineData("contoso.redis.azure.netX:10000")] // almost an Azure Managed Redis host name + [InlineData("contoso.redis.azure.net.X:10000")] // almost an Azure Managed Redis host name + [InlineData("contoso.redis.cache.windows.net:xx")] // Azure Cache for Redis host name with invalid port + [InlineData("contoso.redis.cache.windows.net:")] // Azure Cache for Redis host name with missing port + [InlineData("contoso.redis.azure.net:xx")] // AMR host name with invalid port + [InlineData("contoso.redis.azure.net:")] // AMR host name with missing port + public void ConfigurationOptionsDefaultForNonAzure(string hostAndPort) { - var options = ConfigurationOptions.Parse("redis.contoso.com"); + var options = ConfigurationOptions.Parse(hostAndPort); Assert.True(options.DefaultVersion.Equals(DefaultVersion)); Assert.True(options.AbortOnConnectFail); + Assert.False(options.Ssl); } [Fact] From 7355f0ff65f8789da41310c220e2196b3c27ddf2 Mon Sep 17 00:00:00 2001 From: Philo Date: Wed, 6 May 2026 08:56:52 -0700 Subject: [PATCH 2/2] Update release notes --- docs/ReleaseNotes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 32ec98884..2ae0a91ea 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -12,6 +12,7 @@ Current package versions: - Add Redis 8.8 stream negative acknowledgements (`XNACK`) ([#3058 by @mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/3058)) - Update experimental `GCRA` APIs and wire protocol terminology from "requests" to "tokens", to match server change ([#3051 by @mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/3051)) - Add experimental `Aggregate.Count` support for sorted-set combination operations against Redis 8.8 ([#3059 by @mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/3059)) +- Recognize Azure Managed Redis (AMR) resources in new Azure clouds ([#3068 by @philon-msft](https://github.com/StackExchange/StackExchange.Redis/pull/3068)) ## 2.12.14