Azure Cache For Redis
When your application relies on Azure Redis Cache to work, we also recommend using the Microsoft Entra authentication (which is the default enabled when you create a new one).
First create your Redis Cache and then give access to each users using the menu Data Access Configuration. Unfortunately, at the time of writing this documentation, Redis Cache does not support adding a Microsoft Entra Group as a user, so we have to add each user manually.
The list of users that should be granted access is limited anyway:
- AppServices
- Azure DevOps Service Connection (DbMigrator)
As a developer, if you ever need to have access to Azure Redis, you will need to ask a supervisor to be granted access first.
Using ABP.IO AbpCachingStackExchangeRedisModule
In order to use Azure Cache For Redis services, you will also have to modify your startup module in order to register a "RedisCacheOption" to allow to inject the right credentials. You may fine tune the conditions if you want to use a local Redis for development and Azure Cache for integrated environment.
You will first need add a reference to the following Nuget Package
Microsoft.Azure.StackExchangeRedis
Example
public override void ConfigureServices(ServiceConfigurationContext context)
{
var redisEnabled = configuration["Redis:IsEnabled"];
var configuration = context.Services.GetConfiguration();
if (redisEnabled.IsNullOrEmpty() || bool.Parse(redisEnabled))
{
Configure<RedisCacheOptions>(options =>
{
var redisConfiguration = configuration["Redis:Configuration"];
var configurationOptions = ConfigurationOptions.Parse(redisConfiguration)
.ConfigureForAzureWithTokenCredentialAsync(new ChainedTokenCredential(
new AzureCliCredential(),
new ManagedIdentityCredential(),
new DefaultAzureCredential())).Result;
options.ConfigurationOptions = configurationOptions;
});
}
}