Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
428 stars 182 forks source link

Azure Functions - Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0 #2776

Open jsquire opened 2 weeks ago

jsquire commented 2 weeks ago

Issue Transfer

This issue has been transferred from the Azure SDK for .NET repository, #46577.

Please be aware that @fhtino is the author of the original issue and include them for any questions or replies.

Details

Library name and version

Azure.Data.Tables 12.9.1 and Azure.Storage.Blobs 12.22.2

Describe the bug

Cannot use Azure.Data.Tables and Azure.Storage.Blobs in the same Azure Functions project in VS 2022. When I use the TableClient I get

System.IO.FileNotFoundException: Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Memory.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Azure.Core.RequestContent.Create(Object serializable, ObjectSerializer serializer)
   at Azure.Core.RequestContent.Create(Object serializable)
   at Azure.Data.Tables.TableClient.CreateIfNotExistsAsync(CancellationToken cancellationToken)
   at azfunct1.HelloWorld.Run(HttpRequest req, ILogger log) in xxxxxxx\az-func-cannot-load-assembly\azfunct1\HelloWorld.cs:line 29
var tsc = new TableServiceClient("UseDevelopmentStorage=true");
var tabc = tsc.GetTableClient("zzztest1");
await tabc.CreateIfNotExistsAsync();

Sample project with the issue: https://github.com/fhtino/publicissues/tree/main/az-func-cannot-load-assembly

Workaround: place _FunctionsSkipCleanOutput in the project file:

<PropertyGroup>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

Expected behavior

no errors

Actual behavior

Exception: System.Memory.Data, Version=6.0.0.0 not found

Reproduction Steps

sample here: https://github.com/fhtino/publicissues/tree/main/az-func-cannot-load-assembly

Environment

nodeomega commented 1 week ago

Can confirm. Also facing this issue.

Workaround I have seems to be having System.Memory.Data 6.0.0 installed as a separate NuGet package, building the solution, and copying the System.Memory.Data.dll file to the bin subdirectory in the bin folder, at least in Debug. (I assume Release would be the same way).

Which leads to a folder structure like bin\Debug\net8.0\bin, where I had to copy the dll from bin\Debug\net8.0

For whatever reason, this dependency isn't getting copied to that bin subfolder.

Side effect: Any time I make a change to the Azure Function project and rebuild, the copied System.Memory.Data.dll file disappears, and the error pops up again.

@fhtino - FYI.

Rudresh-Dongre-Contractor commented 1 week ago

Facing the same issue recently while trying to use Azure.Storage.Blobs

Dave-DRX commented 1 week ago

Having same issue with Microsoft.Azure.WebJobs.Extensions.Storage.Queues.

System.Private.CoreLib: Exception has been thrown by the target of an invocation. Microsoft.Azure.WebJobs.Extensions.Storage.Queues: Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0, Culture=neutral. The system cannot find the file specified.

bishwaranjans commented 1 week ago

I am also facing the same issue

Dave-DRX commented 1 week ago

The prescribed workaround (see above: "<_FunctionsSkipCleanOutput>true") worked. I guess I need to update to an isolated process, as recommended by Microsoft, sooner than I thought.

sonofsmog commented 1 week ago

Same issue with using Azure.Security.KeyVault.Secrets and callingSecretClient.GetSecretAsync. @nodeomega's workaround worked for me. Good looking out. Hopefully this gets fixed soon.

mcremer-able commented 1 week ago

Wer are using nodejs and as such can not use @nodeomega 's workaround. Is there any way to maybe downgrade, so it can work again?

shibayan commented 5 days ago

Alternative workaround

  <ItemGroup>
    <FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
  </ItemGroup>
ZmorzynskiK commented 1 day ago

Have exactly the same issue with Microsoft.Azure.WebJobs.Extensions.EventHubs updated to the newest version (6.3.6):

Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0

None of the workarounds worked, so I just reverted to earlier versions of the assemblies and now it works:

<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.EventHubs" Version="6.3.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.SignalRService" Version="1.14.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Tables" Version="1.3.0" />

But this is ridiculous... 🫤

Y-Sindo commented 4 hours ago

Having the same issue for the latest Microsoft.Azure.Functions.Worker.Extensions.SignalRService 1.15.0 version. It blocks users from using managed identity to connect to SignalR Service.