Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mike-jarosch-aw opened this issue Dec 1, 2023 · 0 comments
Labels

Comments

@mike-jarosch-aw
Copy link

  • List of NuGet packages and version that you are using:
  • AutoMapper 12.0.1
  • AutoMapper.Collection.EntityFrameworkCore 9.0.0
  • AutoMapper.Extensions.Microsoft.DependencyInjection 12.0.1
  • Microsoft.ApplicationInsights.AspNetCore 2.21.0
  • Microsoft.AspNetCore.OpenApi 7.0.4
  • Microsoft.Azure.AppConfiguration.AspNetCore 7.0.0
  • Microsoft.EntityFrameworkCore 7.0.14
  • Microsoft.EntityFrameworkCore.InMemory 7.0.14
  • Swashbuckle.AspNetCore 6.4.0
  • 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

  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

  • 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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant