skip to Main Content

I run a .NET Core application running on 5 Azure App Service instances.

I am going to migrate my configuration to Azure App Configuration, where the SDK (NuGet package) caches the values in-memory for a specified time (i.e. 30 minutes).

Considering the life-cycle of an instance, is this in-memory caching recommended over caching the values in Azure Cache for Redis?

2

Answers


  1. Caching App Configuration values in Azure Cache for Redis

    • Create Azure Cache for Redis in the Azure Portal.

    enter image description here

    Using App Configuration values in Azure Cache for Redis is simple and can increase the performance of the Azure App.

    In .NET Application install the Microsoft.Extensions.Caching.StackExchangeRedis NuGet Package.

    builder.AddAzureAppConfiguration(options => 
    { 
       options.Connect(redisCache, "Your App Configuration Connection String from Portal"); 
    });
    

    Code reference taken from App Configuration

    Thanks @Jaydeep Patil for the explanation.

    When we use In-Memory Cache then in that case data is stored in the application server memory and whenever we need then we fetch data from that and use it wherever we need it.

    If your application has only one instance, then using In-memory cache is a better option.

    Thanks @Krunal Trivedi for a Step-by-Step Demo.

    Azure Redis Cache is an in-memory database and that means if there is a hardware failure, there is a potential for data loss.

    With the basic and standard pricing tier, you can have just a single node and if that fails, you have got no persistence of the data.

    To persist and recover from hardware failure, use a premium pricing tier implementation.

    As you have mentioned caches the values for a specified time (30 min), then using In-memory cache is advised.

    Login or Signup to reply.
  2. At a high level, both Azure App Configuration and Azure Cache for Redis are key-value storage, but they are tailored and optimized for different scenarios. You may evaluate based on your need.

    Azure App Configuration is for configuration scenarios. Here are a few things it offers:

    • Tools to help import/export configuration.
    • Support for GitHub action and Azure Pipelines to integrate App Configuration in your CI/CD.
    • Revision history to track changes and restore changes in case anything goes wrong.
    • Client libraries to use App Configuration just as another configuration source to your app, so the code change to your app is minimal.
    • Integration with other Azure services like App Service for configuration scenarios.

    Azure Cache for Redis is for distributed caching scenarios. You have your dedicated deployment. Your data may be changed frequently, but you don’t really care about the history of changes.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search