Hello,
Microsoft is signaling the replacement of Azure Cache for Redis with Azure Managed Redis. Is there anything to consider in ASP.NET Zero for this migration?
https://learn.microsoft.com/pt-br/azure/redis/migrate/migrate-basic-standard-premium-understand
thanks.
3 Answer(s)
-
0
Hi @ricardo
Thank you for reaching out. The short answer is that migrating to Azure Managed Redis is very straightforward, and there is nothing to worry about from a framework perspective.
ASP.NET Zero comes with Redis pre wired but disabled by default. Here is how the architecture handles it:
- The
Abp.RedisCacheNuGet package is referenced inWeb.Core.csproj. AbpRedisCacheModuleis registered as a module dependency inAbpZeroTemplateWebCoreModule.cs.- The
UseRedis()activation call is commented out, meaning in-memory caching is used by default. - Most importantly, all caching in the framework goes through ABP's
ICacheManagerabstraction, not through directStackExchange.Rediscalls.
This means there is zero coupling to any specific Redis server version, protocol, or feature.
What to Consider When Migrating
Based on the differences with Azure Managed Redis, here is how it impacts an ASP.NET Zero application:
| Concern | Impact | Details | | :--- | :--- | :--- | | Connection string format | Config change only | Azure Managed Redis uses a different DNS suffix (
<region>.redis.azure.net) and port (10000instead of6380/6379). Update yourappsettings.jsonaccordingly. | | TLS | Config change only | Azure Managed Redis supports only one mode (TLS or non-TLS) at creation time. Addssl=Trueto your connection string. | | Single database limitation | No impact | ASP.NET Zero usesDatabaseId: -1(the default database). No multiple database usage exists out of the box. | | Clustering (enabled by default) | Low risk |Abp.RedisCacheusesStackExchange.Redisinternally, which fully supports cluster-aware connections. For small caches (<25 GB), you can also use the Nonclustered mode. | | Keyspace notifications (not available)| No impact | ASP.NET Zero does not use keyspace notifications. | | Redis modules | No impact | ASP.NET Zero does not use RediSearch, RedisJSON, or any specific Redis modules. | | VNet injection (not supported)| Check your deployment | If you currently use VNet injection for network isolation, you will need to switch to Azure Private Link. | | Entra ID RBAC (not supported yet)| Check your deployment | If you are using Entra ID RBAC for Redis access, please note this isn't available yet on Azure Managed Redis. |Migration Steps for ASP.NET Zero
If Redis is already enabled in your production environment, the migration involves only configuration changes:
- Update connection strings in
appsettings.json(and any environment-specific overrides):"ConnectionString": "your-cache.eastus.redis.azure.net:10000,password=YOUR_KEY,ssl=True,abortConnect=False" - Update Docker Compose variables if using containerized deployments (e.g., in
docker-compose-host.yml,docker-compose-mvc.yml). - Choose the right SKU: Azure Managed Redis reserves ~20% of memory for overhead. If your current cache is a C3 (13 GB), look for an AMR SKU with at least 13 GB of usable memory. The "Balanced" tier is a safe starting point.
- No code changes are required the
ICacheManagerabstraction handles the rest automatically.
ASP.NET Zero's architecture makes this migration seamless. The ABP caching abstraction layer means the framework has no dependency on Redis-specific features, clustering modes, database selection, or protocol details. The migration is purely a configuration-level change update your connection strings, ensure TLS is enabled, and you are good to go.
If you need any assistance after applying these changes, please do not hesitate to contact us.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) - The
-
0
If you want to use Entra ID RBAC it is possible.
We simply replaced the IAbpRedisCacheDatabaseProvider with our own implementation.
//Taken from here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/292754bf5368757da2e987b9876a057c4fbffb56/src/Abp.RedisCache/Runtime/Caching/Redis/AbpRedisCacheDatabaseProvider.cs#L10 //But adapted to support azure default credentials connecting. public class ProjectNameAbpRedisCacheDatabaseProvider : IAbpRedisCacheDatabaseProvider, ISingletonDependency { private readonly AbpRedisCacheOptions _options; private readonly Lazy<ConnectionMultiplexer> _connectionMultiplexer;
/// <summary> /// Initializes a new instance of the <see cref="AbpRedisCacheDatabaseProvider"/> class. /// </summary> public ProjectNameAbpRedisCacheDatabaseProvider(AbpRedisCacheOptions options) { _options = options; _connectionMultiplexer = new Lazy<ConnectionMultiplexer>(CreateConnectionMultiplexer); } /// <summary> /// Gets the database connection. /// </summary> public IDatabase GetDatabase() { return _connectionMultiplexer.Value.GetDatabase(_options.DatabaseId); } private ConnectionMultiplexer CreateConnectionMultiplexer() { var configurationOptions = ConfigurationOptions.Parse(_options.ConnectionString).ConfigureForAzureWithTokenCredentialAsync(new DefaultAzureCredential()).WaitAndUnwrapException(); return ConnectionMultiplexer.Connect(configurationOptions); }}
Then in your Module add the following
Configuration.ReplaceService<IAbpRedisCacheDatabaseProvider, ProjectNameAbpRedisCacheDatabaseProvider>(DependencyLifeStyle.Singleton);Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @rickfrankel
Thank you for sharing this.
Yes, that approach makes sense. Since ASP.NET Zero uses
IAbpRedisCacheDatabaseProvideras the abstraction point, replacing it with a custom implementation is a valid way to enable Entra ID RBAC authentication for Redis.Your example is especially helpful because it shows that the existing
AbpRedisCacheDatabaseProvidercan be adapted withDefaultAzureCredentialandConfigureForAzureWithTokenCredentialAsync(...)without requiring broader changes in the caching layer.We appreciate you sharing the implementation details here. This should be useful for others who want to use Azure Managed Redis with Entra ID RBAC in ASP.NET Zero.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)