azure-functions-host icon indicating copy to clipboard operation
azure-functions-host copied to clipboard

Reference Microsoft.Identity.Web 1.25.1 - Could not load file or assembly Microsoft.IdentityModel.Logging

Open czb182 opened this issue 2 years ago • 5 comments

Microsoft.Net.SDK.Functions 4.1.1 .net6 Azure Functions Host 4.6.1 (via core-tools in visual studio)

I have a library that references Microsoft.Identity.Web 1.25.1 which is referenced by my functions project. At runtime I get "Microsoft.Identity.Web: Could not load file or assembly 'Microsoft.IdentityModel.Logging, Version=6.20.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified."

Previously my library had referenced Microsoft.Identity.Web 1.23.1 and it was working.

For my functions project Microsoft.IdentityModel.Logging exist in top bin folder, but not the nested bin folder. If I copy to nested bin folder manually it runs without issue.

czb182 avatar Jul 28 '22 17:07 czb182

It works fine if my library references Microsoft.Identity.Web 1.25.0.

Looks like there is a new dependency in Microsoft.Identity.Web 1.25.1. Microsoft.IdentityModel.LoggingExtensions which itself has a dependency on Microsoft.IdentityModel.Abstractions.

czb182 avatar Jul 28 '22 17:07 czb182

It works if I add this to function csproj

<_functionsskipcleanoutput>true

then the Microsoft.IdentityModel.Logging file exist in the nested bin folder and no exceptions.

I dont know what all this would affect, so hesitant to use this work around.

czb182 avatar Jul 28 '22 19:07 czb182

any other info needed from me?

czb182 avatar Aug 09 '22 14:08 czb182

hi @czb182 I don't know if it's still useful but based on this message I believe the _FunctionsSkipCleanOutput is safe to be used

thiagomarinho avatar Oct 03 '22 23:10 thiagomarinho

hi @czb182 I don't know if it's still useful but based on this message I believe the _FunctionsSkipCleanOutput is safe to be used

yes, i believe it currently is.

I think there is a 'whitelist' of dll's maintained somewhere in repo here of dll's to copy or not, which I think is proper fix, but not sure. I have not tested latest version to know if still issue or not.

czb182 avatar Oct 12 '22 13:10 czb182

Microsoft.Identity.Web version 1.25.3 still fails. And it works OK if to downgrade to version 1.25.0

My case: the FunctionApp uses the following packages

  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.8.1" />
    <PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.25.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
  </ItemGroup>

dmitry-pavlov avatar Oct 18 '22 16:10 dmitry-pavlov

This is still an issue. Was just updating to latest identity.web, 2.7.0 and it is failing on the exact same thing, just different version.

Could not load file or assembly 'Microsoft.IdentityModel.Logging, Version=6.27.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Azure Functions Core Tools Core Tools Version: 4.0.5095 Commit hash: N/A (64-bit) Function Runtime Version: 4.16.5.20396

Can we please get this fixed. I searched online and people are suggested to just use older versions or work around <_FunctionsSkipCleanOutput>true

Adding work around is not practical for me since dozens of functions across a dozen teams and I don't know all the downstream affects that is going to have.

czb182 avatar Mar 30 '23 19:03 czb182

maybe need to add reference to Microsoft.IdentityModel.Logging in webhost? looks like thats what was done for Microsoft.IdentityModel.tokens

https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

czb182 avatar Mar 30 '23 19:03 czb182

@czb182 I had the same use and was able to resolve using this workaround Basically you need to add this on your csproj file:

<PropertyGroup>
  <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
</PropertyGroup>

rfabro avatar Apr 02 '23 18:04 rfabro

Yes, im aware of that, and it does fix issue, however I do think that is a proper solution, so requesting one.

@fabiocav

czb182 avatar Apr 03 '23 13:04 czb182

It would be awesome to get this resolved. stuck on Microsoft.Identity.Web 1.15.1 until azure functions can be fixed. MS Identity team doing great work, but then its not consumable because of a different team.

czb182 avatar Apr 21 '23 18:04 czb182