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

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

Open
jsquire opened this issue Oct 12, 2024 · 29 comments · Fixed by #10610
Open
Assignees

Comments

@jsquire
Copy link
Member

jsquire commented Oct 12, 2024

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

  • Visual Studio 2022 17.11.5
  • Azure Functions Core Tools / Core Tools Version: 4.0.6518 (64-bit) / Function Runtime Version: 4.35.4.23179
@nodeomega
Copy link

nodeomega commented Oct 14, 2024

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

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

@Dave-DRX
Copy link

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
Copy link

I am also facing the same issue

@Dave-DRX
Copy link

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

@sonofsmog
Copy link

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
Copy link

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
Copy link

Alternative workaround

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

@ZmorzynskiK

This comment has been minimized.

@Y-Sindo
Copy link
Member

Y-Sindo commented Oct 28, 2024

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
Copy link

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
Copy link

sastru commented Oct 28, 2024

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.

@fabiocav fabiocav transferred this issue from Azure/azure-functions-dotnet-worker Oct 29, 2024
@stasaristic
Copy link

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
Copy link
Member

Y-Sindo commented Oct 30, 2024

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:

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

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

@Arash-Sabet
Copy link

Arash-Sabet commented Oct 31, 2024

<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
Copy link

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
Copy link

pingu2k4 commented Nov 6, 2024

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
Copy link
Member

fabiocav commented Nov 7, 2024

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
Copy link
Member

fabiocav commented Nov 7, 2024

Keeping this open to track deployment.

@OrlandoPaglione
Copy link

OrlandoPaglione commented Nov 11, 2024

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
Copy link

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

@LockTar
Copy link

LockTar commented Nov 23, 2024

Running .NET 8 in process.

This is working for me deploying in Azure but locally I still have another issue.

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

Any idea when a fix will be available?

Locally I still have the following issue:
Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0

@rclark-christies
Copy link

@LockTar this looks to be unrelated - but I resolved the same issue locally by updating to the latest Azure Functions Core Tools.

@LockTar
Copy link

LockTar commented Nov 27, 2024

@LockTar this looks to be unrelated - but I resolved the same issue locally by updating to the latest Azure Functions Core Tools.

I also think it's unrelated but everything was fine before upgrading to .NET 8. Tried your solution (didn't have the tools because I'm using visual studio 2022 latest with latest tools) but without luck. I will try to convert the project to isolated ASAP.

@mattgwagner
Copy link

This started blowing up my running Azure Function app even though I had not made any code changes or deployments in 3+ weeks. Incredibly frustrating for nothing that I changed!

System.IO.FileNotFoundException:
   at Azure.RequestFailedException.AppendContentAndHeaders (Azure.Core, Version=1.44.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at Azure.RequestFailedException.CreateExceptionDetails (Azure.Core, Version=1.44.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at Azure.RequestFailedException..ctor (Azure.Core, Version=1.44.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at Azure.Storage.Queues.MessagesRestClient+<EnqueueAsync>d__14.MoveNext (Azure.Storage.Queues, Version=12.19.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Azure.Storage.Queues.QueueClient+<SendMessageInternal>d__82.MoveNext (Azure.Storage.Queues, Version=12.19.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Azure.Storage.Queues.QueueClient+<SendMessageAsync>d__81.MoveNext (Azure.Storage.Queues, Version=12.19.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Extensions.Storage.Common.StorageQueueExtensions+<AddMessageAndCreateIfNotExistsAsync>d__0.MoveNext (Microsoft.Azure.WebJobs.Extensions.Storage.Queues, Version=5.3.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Queues.QueueProcessor+<CopyMessageToPoisonQueueAsync>d__14.MoveNext (Microsoft.Azure.WebJobs.Extensions.Storage.Queues, Version=5.3.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Queues.QueueProcessor+<HandlePoisonMessageAsync>d__13.MoveNext (Microsoft.Azure.WebJobs.Extensions.Storage.Queues, Version=5.3.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Queues.QueueProcessor+<BeginProcessingMessageAsync>d__11.MoveNext (Microsoft.Azure.WebJobs.Extensions.Storage.Queues, Version=5.3.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Extensions.Storage.Common.Listeners.QueueListener+<ProcessMessageAsync>d__44.MoveNext (Microsoft.Azure.WebJobs.Extensions.Storage.Queues, Version=5.3.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)

@VladDerptastic
Copy link

VladDerptastic commented Dec 1, 2024

Keeping this open to track deployment.

Hey @fabiocav, sorry to bother, but do you know if this is this anywhere close to being resolved the 'proper' way?

@MikeP707
Copy link

MikeP707 commented Dec 2, 2024

I have also the same problem when I try to use Microsoft.Azure.Functions.Worker.Extensions.Timer 4.3.1
Timer trigger attribute on TimerInfo.

Environment: dotnet-isolated
Dotnet: 8 and 9 the same
Error: Azure.Core: Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0'

I tried solutions with _FunctionsSkipCleanOutput and Functions preserved dependencies but it doesn't work. It look like when I replace it by Http trigger it works.
Do you have any ideas how to fix this error or replace this timer by another one?

@MarGraz
Copy link

MarGraz commented Dec 3, 2024

Alternative workaround

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

Thank you, I resolved using this workaround! ☺️

In my case the issue was related with the Azure Function v. 4, upgrade from .NET 6 to .NET 8, where I was using the class DefaultAzureCredential (Azure.Identity) in the Startup class.

@JackDC16
Copy link

JackDC16 commented Dec 6, 2024

Alternative workaround

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

This workaround worked for me too.

I hit the issue after upgrading Azure.Core from 1.42.0 to 1.44.1 in an Azure Functions v4 app on .NET 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.