Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 442 forks source link

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

Open jsquire opened 1 month ago

jsquire commented 1 month 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 month 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 month ago

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

Dave-DRX commented 1 month 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 month ago

I am also facing the same issue

Dave-DRX commented 1 month 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 month 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 month 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 1 month ago

Alternative workaround

  <ItemGroup>
    <FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
  </ItemGroup>
ZmorzynskiK commented 3 weeks 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" />
Y-Sindo commented 3 weeks 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.

DavidKoolen commented 3 weeks ago

We have the same issue with Microsoft.Azure.Functions.Worker.Extensions.SignalRService 1.15.0. Downgrade to 1.14.1 resolves the issue and we can use the System-assigned managed identity again.

sastru commented 3 weeks ago

Alternative workaround

<ItemGroup>
 <FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
</ItemGroup>

I can confirm that this alone as the single change, made it work as expected.

stasaristic commented 3 weeks ago

We have the same issue with Microsoft.Azure.Functions.Worker.Extensions.SignalRService 1.15.0. Downgrade to 1.14.1 resolves the issue and we can use the System-assigned managed identity again.

Had the same issue, this is the only thing that solved it. Unfortunately version 1.15.0 kept giving me: Microsoft.Azure.WebJobs.Extensions.EventHubs: Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0, Culture=neutral'. The system cannot find the file specified.

Y-Sindo commented 3 weeks ago

Hi @jsquire , the workarounds that add some properties in the project file still don't work for Microsoft.Azure.Functions.Worker.Extensions.SignalRService 1.15.0.

The not working workarounds include:

If you need any other information from me, please let me know.

Arash-Sabet commented 3 weeks ago
<ItemGroup>
 <FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
</ItemGroup>

This workaround did not work. We need a permanent solution. This issue must be addressed ASAP as it's a roadblock.

jameseedi commented 2 weeks ago

I spent a significant amount of time resolving an issue involving dependencies on System.Memory.Data 6.0.0. Locally, I managed to get things working by manually replacing the DLL with version 6.0.0 in the AzureFunctionsTools folder at:

C:\Users\User\AppData\Local\AzureFunctionsTools\Releases\4.100.0\cli_x64

However, on Azure, this isn't possible due to the lack of access for patching DLLs directly. After extensive troubleshooting, I discovered that the recent upgrade to Microsoft.Azure.Functions.Worker.Extensions.SignalRService 1.15.0 was the root cause. Downgrading to 1.14.1 resolved the issue.

This complex dependency setup clearly needs addressing. Ideally, we should also have more control over configuration in Azure to facilitate such troubleshooting. If there are any ways to achieve this, please let me know.

Having used Azure Functions since v1, I’ve found it to be a convenient but often frustrating service. The migration paths (e.g., isolated functions, v1 to v2) have been rocky, and these issues make maintaining reliable services challenging. I encourage proactive measures to improve stability in the Azure Functions ecosystem. 🙏

pingu2k4 commented 2 weeks ago

I've got the same issue here regarding the SignalRService package. None of the workarounds fix anything in this instance, other than reverting to 1.14.1, including things I had tried from other places (for example using assembly binding redirects)

Would love to see a resolution for this.

fabiocav commented 2 weeks ago

The current mitigation is to either downgrade the package bringing the dependency, or update the project configuration mentioned in the issue if using the .NET in-proc model:

<ItemGroup>
    <FunctionsPreservedDependencies Include="System.Memory.Data.dll" />
</ItemGroup>

For the .NET Isolated model, the impacted package (SignalR) must be downgraded. We will work with the appropriate team to delist in the meantime, as this was an invalid update. We'll also be working with them to ensure this issue is prevented in the future.

A fix for this will be rolling out with the next host deployment. Thank you all for the report and patience.

fabiocav commented 2 weeks ago

Keeping this open to track deployment.

OrlandoPaglione commented 1 week ago

Hi., all

"I spent a week dealing with the System.Data issue, and this solution solved it:

<FunctionsPreservedDependencies Include="System.Memory.Data.dll" />

I would also like to know if there is a way to isolate the app from dependencies, as these types of errors undermine the system's credibility. With just a single tool update, everything can simply stop working, and you don’t get reliable error logs to understand what’s happening."

Would you like more information on isolating app dependencies in Azure Functions?

Thanks. Orlando

richardhitchins commented 1 week ago

Downgrading Microsoft.Azure.WebJobs.Extensions.Storage from 5.3.3 to 5.3.2 worked for me