microsoft / ApplicationInsights-dotnet

ApplicationInsights-dotnet
MIT License
565 stars 287 forks source link

Adding the AppilcationInsights SDK to an app using UseEntityFrameworkCoreModel from AutoMapper.Collection.EFCore causes IOptionsMonitor to stop updating with config changes #2833

Open a60915 opened 12 months ago

a60915 commented 12 months ago

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

  1. Create test Azure resources (App Insights and App Configuration) and note the connection strings.
  2. Update the appsettings.Development.json with the connection strings.
  3. 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.

image

Steps

  1. Run the application in visual studio.
  2. Execute the "test/sayHello" endpoint and see it displays the name in App Configuration
  3. Execute the "test/showConfig" endpoint and see it contains the Name and Sentinel value from App Configuration
  4. 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.
  5. Update the Name and Sentinel values in App Configuration.
  6. Execute the "test/sayHello" endpoint a few time and see it still displays the previous Name.
  7. Execute the "test/showConfig" endpoint and see it contains the updated Name and Sentinel values.

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