Dear ASPZERO Support,
We are encountering an issue with our Azure deployment - we use Angular + ASPNET Core ASPZERO V12:
In our application, we are using an Angular app with an ASP.NET Core API, along with the ABP Boilerplate and custom user-based settings stored in the AbpSettings table. In our on-premise environment, when we change settings via the UI, the updates are applied immediately.
However, in the Azure environment, where the Angular app and the ASP.NET Core Web API are deployed as separate App Services, changes to the AbpSettings table via the UI do not take effect immediately. We need to confirm the changes multiple times before they are actually reflected in the application.
Both environments are connected to SQL Server — one running locally, and the other using an Azure SQL Managed Instance.
Could this be due to caching, or do you have any insight into why the settings changes in the Azure environment are not immediately applied?
Thank you in advance for your support.
8 Answer(s)
-
0
Could it be a problem with Instance count 2 in Azure - we are running 2 instances? With some caching issue?
-
0
Hi @pliaspzero
Yes, this is definitely related to multiple instances. I suggest you to check https://docs.aspnetzero.com/aspnet-core-angular/latest/Clustered-Environment
-
0
Thank you! so solution would be to setup REdis Cache (in Azure) and ...
Configuration.Caching.UseRedis(options => { options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"]; options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId"); });
-
0
Could it also be done like this?
Clear Cache on Setting Change
ABP Framework uses caching for settings to improve performance. If the cache is not cleared immediately after a setting is updated, one of the instances may continue using the outdated settings.
To ensure the cache is cleared after saving changes, you should explicitly clear the cache after updating the ABP Settings. Here’s how you can handle cache invalidation programmatically after saving settings:
csharp
// Clear cache after settings are saved await _cacheManager.GetCache("AbpSettingsCache").ClearAsync();
This ensures that the cache is cleared and both instances will load the updated settings from the database.
-
0
Hi,
This will not work becuase each instance will use its own memory cache if you have multiple instances.
-
0
Hi,
thanks - when I include this - we have also installations where UseRedis is not needed - then if no redis is configured - how is the behaviour then?
Configuration.Caching.UseRedis(options => { options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"]; options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId"); });
-
0
... would do something like this: // Check the Redis connection string var redisConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"]; if (!string.Equals(redisConnectionString, "localhost", StringComparison.OrdinalIgnoreCase)) { // Uncomment this line to use Redis cache instead of in-memory cache. // See app.config for Redis configuration and connection string Configuration.Caching.UseRedis(options => { options.ConnectionString = redisConnectionString; options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId"); }); }
-
0
Hi @pliaspzero
Sorry for my late reply, I missed your post somehow. Yes, you also need to make this configuration.