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

[Bug] Dependency on System.Diagnostics.DiagnosticSource (>= 7.0.2) in version 4.58.0 missing in .NET 6 Azure Functions #4456

Closed
pmaytak opened this issue Dec 6, 2023 · 11 comments · Fixed by #4487 or #4486

Comments

@pmaytak
Copy link
Contributor

pmaytak commented Dec 6, 2023

Discussed in https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/discussions/4455

Originally posted by Ozindar December 6, 2023
We've got a .NET 6.0 Azure Function using the Identity.Client. This worked fine with 4.57. With a recently deploy we've upgraded to 4.58 but in Azure this triggers a File not found when it's searching for the DiagnosticsSource version 7 assembly.
"dotnet publish" does not seem put that dll in the output folder. For the moment I've pinned the Identity.Client to 4.58.
Is there a viable solution to keep using the latest Identity.Client in combination with a .NET6 Azure Function and what would be the best approach?

@pmaytak
Copy link
Contributor Author

pmaytak commented Dec 6, 2023

@Ozindar Does this repro if you try .NET 7 or 8 Azure Function? Can DiagnosticSource package be used in Azure Functions in general? For ex, in your app can you target MSAL 4.57 and just add a reference to DiagnosticSource v6.0.0, will that work?

@pmaytak pmaytak self-assigned this Dec 7, 2023
@pmaytak pmaytak modified the milestones: 4.58.1, 4.59.0 Dec 7, 2023
@pmaytak
Copy link
Contributor Author

pmaytak commented Dec 8, 2023

@Ozindar I wasn't able to repro. I created and published a .NET 6 HTTP Trigger Function with MSAL 4.58.1. Tried with framework-dependent and self-contained deployment modes, portable and win-x86 runtimes, integrated and classic pipelines. App compiled and ran fine. Please provide and repro and more details on any related deployment settings that can help repro.

@Dolphinsimon
Copy link

We have met the same errors in Azure Functions.
Inner exception System.IO.FileNotFoundException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw: at Microsoft.Identity.Client.Platforms.Features.OpenTelemetry.OtelInstrumentation.Microsoft.Identity.Client.TelemetryCore.OpenTelemetry.IOtelInstrumentation.LogFailedMetrics (Microsoft.Identity.Client, Version=4.58.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae) at Microsoft.Identity.Client.Internal.Requests.RequestBase+<RunAsync>d__12.MoveNext (Microsoft.Identity.Client, Version=4.58.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor+<ExecuteAsync>d__3.MoveNext (Microsoft.Identity.Client, Version=4.58.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

@bgavrilMS
Copy link
Member

We will investigate. For now stick to MSAL 4.57, as it does not have this dependency.

@pmaytak
Copy link
Contributor Author

pmaytak commented Dec 11, 2023

Thanks @Dolphinsimon. Seems like it's not a compile-time or publish error, but a runtime error, as I was able to publish successfully but didn't try running MSAL.

@jmprieur
Copy link
Contributor

It's because Azure functions don't run the application with the references that you build. We have the same issue with IdentityModel
They (Azure functions) need to upgrade to a new version of MSAL.NET

@Dolphinsimon
Copy link

Dolphinsimon commented Dec 12, 2023

@pmaytak Yes, Azure Function will clean the output libraries before publishing to the cloud. If the library was already in the function runtime, then the library will be deleted. For this issue, the System.Diagnostics.DiagnosticSource is in the function .NET runtime, but the version is not 7.0.2, the .NET v4 runtime is only support .NET6.0 libraries, the version is 6.x.
To fix this issue, you can set the library dependency library version to 6.x or Add <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to a <PropertyGroup> in the function app’s .csproj file.

@bgavrilMS
Copy link
Member

bgavrilMS commented Dec 12, 2023

@GeoK @neha-bhargava - do you know if System.Diagnostics.DiagnosticSource version 6.x would work instead of version 7.x for the MSAL scenarios?

@bgavrilMS
Copy link
Member

bgavrilMS commented Jan 3, 2024

Seems to be a known issue with Azure Functions. Looking for workarounds....

We are looking at disabling the OTEL functionality if this exception occurs, as it is not critical.

@pmaytak
Copy link
Contributor Author

pmaytak commented Jan 6, 2024

@pmaytak
Copy link
Contributor Author

pmaytak commented Jan 17, 2024

@Ozindar @Dolphinsimon MSAL 4.59.0 was released that references DiagnosticSource 6.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment