AppConfiguration icon indicating copy to clipboard operation
AppConfiguration copied to clipboard

UseAzureAppConfiguration and AzureAppConfigurationRefreshMiddleware break context execution

Open fjbelizon opened this issue 1 year ago • 14 comments

I have detected that if we make use of ‘UseAzureAppConfiguration’, which in turn internally injects the middleware ‘AzureAppConfigurationRefreshMiddleware’, it breaks the execution of the context of the Eternal Orchestration Functions.

I am using Azure Isolated Function in NET 8, using package ‘Microsoft.Azure.AppConfiguration.Functions.Worker’ in version 7.2.0.

The middleware internally performs an ‘ExecutionContext.SuppressFlow()’, which breaks the execution flow of the context: https://learn.microsoft.com/en-us/dotnet/api/system.threading.executioncontext.suppressflow?view=net-8.0

Right now the solution I am applying is to use ‘AddAzureAppConfiguration’ without ‘UseAzureAppConfiguration’. In my orchestrator constructor I inject ‘IConfigurationRefresherProvider’ to use the configuration refresher in the orchestrator activities.

The problem is not described anywhere and should be checked. Thanks in advance.

fjbelizon avatar May 10 '24 07:05 fjbelizon

Hi @fjbelizon, we got a similar issue about durable functions being broken a while back, but ExecutionContext.SuppressFlow() wasn't mentioned. In the discussion there as well as in the linked issue that's in the Azure Functions repo, it was thought that the problem was not specific to the Azure App Configuration middleware.

One helpful test would be to see if version 6.0.1 of the provider also causes this issue for you, since that was before we added the call to SuppressFlow(). If the issue goes away, I'll need to update that original issue. Thanks!

amerjusupovic avatar May 13 '24 21:05 amerjusupovic

Hi @amerjusupovic. Ok, I'm going to do the test

fjbelizon avatar May 15 '24 06:05 fjbelizon

@amerjusupovic yes, same problem. Version 6.0.1 also breaks the execution of Eternal Functions.

I attach the code sample for you to test: bug-azure-app-configuration-refresh-middleware.zip. I've put two ‘TODO’ tags for you to comment/uncomment the lines that make the execution work/fail.

I look forward to your review. Thanks in advance.

fjbelizon avatar May 15 '24 10:05 fjbelizon

Any news about this issue? Thanks in advance

sparraguerra avatar May 23 '24 13:05 sparraguerra

@amerjusupovic

Given there was a repro with 6.0.1 do you believe it would be the same issue as here?

jimmyca15 avatar May 28 '24 16:05 jimmyca15

@jimmyca15 Yes I believe so, I know someone on the functions team believed it wasn't an issue with the .NET provider library at first, but from this it seems like it is something we introduced. I'll look into this more and see if we can fix this portion of the code while still solving the HttpContext issue that originally required this change.

amerjusupovic avatar May 28 '24 20:05 amerjusupovic

Ok, thanks @amerjusupovic 👌

fjbelizon avatar May 29 '24 07:05 fjbelizon

This looks like a dupe of this issue. I don't think ExecutionContext.SuppressFlow has any involvement here. This supported by 6.0.1 reproing as well.

jimmyca15 avatar May 31 '24 23:05 jimmyca15

@amerjusupovic if you can confirm this is a dupe of the aforementioned issue we should merge this issue into the existing one which the Functions team mentioned they need to solve on their end.

jimmyca15 avatar May 31 '24 23:05 jimmyca15

Sorry for the confusion in my previous response, yes the repro in 6.0.1 suggests it's the same issue, and that was before the call to SuppressFlow was added. This should be merged with the existing one.

amerjusupovic avatar Jun 03 '24 19:06 amerjusupovic

is there any news about this issue? or any alternative, thanks in advance!!

BrunoCandia avatar Jul 02 '24 19:07 BrunoCandia