Adding the AppilcationInsights SDK to an app using UseEntityFrameworkCoreModel from AutoMapper.Collection.EFCore causes IOptionsMonitor to stop updating with config changes #2833
Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file):
net7.0
Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.):
Windows
Azure App Services
Describe the bug
Adding the Application Insights SDK to your application using UseEntityFrameworkCoreModel from AutoMapper.Collection.EntityFrameworkCore will cause any IOptionsMonitors to stop updating with config changes.
I have attached a sample project that recreates it. It does require an Azure Application Insights and Azure App Configuration for the best visibility of the bug.
To Reproduce
Setup
Create test Azure resources (App Insights and App Configuration) and note the connection strings.
Update the appsettings.Development.json with the connection strings.
In App Configuration, add a "Test:Name" variable with any value. Add a "Test:Sentinel" value with a Label of "Test" and a value of 1.
Steps
Run the application in visual studio.
Execute the "test/sayHello" endpoint and see it displays the name in App Configuration
Execute the "test/showConfig" endpoint and see it contains the Name and Sentinel value from App Configuration
Execute the "facts/getFact" endpoint and enjoy the fun dog fact. The remote call is not necessary, I just wanted the endpoint to do something. The important piece is that it will receive an IMapper from the DI container.
Update the Name and Sentinel values in App Configuration.
Execute the "test/sayHello" endpoint a few time and see it still displays the previous Name.
Execute the "test/showConfig" endpoint and see it contains the updated Name and Sentinel values.
Notes
You can re-create the issue without App Configuration, but you will not see the "test/showConfig" update with new values. I believe this is because the settings file monitoring uses the same functionality that is used to update OptionsMonitors
For immediate support relating to the Application Insights .NET SDK we encourage you to file an Azure Support Request with Microsoft Azure instead of filing a GitHub Issue in this repository.
You can do so by going online to the Azure portal and submitting a support request. Access to subscription management and billing support is included with your Microsoft Azure subscription, and technical support is provided through one of the Azure Support Plans. For step-by-step guidance for the Azure portal, see How to create an Azure support request. Alternatively, you can create and manage your support tickets programmatically using the Azure Support ticket REST API
*.csproj
file):Describe the bug
Adding the Application Insights SDK to your application using UseEntityFrameworkCoreModel from AutoMapper.Collection.EntityFrameworkCore will cause any IOptionsMonitors to stop updating with config changes.
I have attached a sample project that recreates it. It does require an Azure Application Insights and Azure App Configuration for the best visibility of the bug.
To Reproduce
Setup
Steps
Notes
ConfigurationRefresh.zip
For Immediate Support
For immediate support relating to the Application Insights .NET SDK we encourage you to file an Azure Support Request with Microsoft Azure instead of filing a GitHub Issue in this repository. You can do so by going online to the Azure portal and submitting a support request. Access to subscription management and billing support is included with your Microsoft Azure subscription, and technical support is provided through one of the Azure Support Plans. For step-by-step guidance for the Azure portal, see How to create an Azure support request. Alternatively, you can create and manage your support tickets programmatically using the Azure Support ticket REST API