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

System.Text.Json Not working on Azure Functions v3 #1898

Closed
notaroobob opened this issue May 18, 2021 · 7 comments
Closed

System.Text.Json Not working on Azure Functions v3 #1898

notaroobob opened this issue May 18, 2021 · 7 comments

Comments

@notaroobob
Copy link

System.Text.Json 5.0.2 brings with it an update to System.Text.Encodings.Web of 5.0.1.

The Dot net Runtimes for Azure Functions (linux in my case) is not allowing any executable to fire up. Specifically it's throwing an error that System.Text.Encodings.Web 5.0.0 is not found (which is true because it's now 5.0.1). Trying to force an update to 5.0.1 for Encodings.Web via nuget packages did not resolve the issue.

Reverting to System.Text.Json 5.0.1 (and System.Text.Encodings.Web to 5.0.0) fixes the issue for now, but I'll be needing to walk on egg shells for the next couple of months until Dot Net 6 consolidates and ships as default for the greater azure eco system.

Configuration
Which version of .NET is the code running on? - dot net core 3.1
What OS and version, and what distro if applicable? - Locally Mac OS 11.3.1. Deployed to Linux Consumption Function Tier
What is the architecture (x64, x86, ARM, ARM64)? x64
Do you know whether it is specific to that configuration? Unknown, assumption is no
Regression?
Resolved via downgrading to System.Text.Json 5.0.1

Call Stack: RuntimeAssembly.InternalLoadAssemblyName() at REDACTED RuntimeAssembly.cs:line 345 Assembly.Load() AssemblyLoadContext.LoadFromAssemblyName() FunctionAssemblyLoadContext.TryLoadHostEnvironmentAssembly() at D:\a\1\s\src\WebJobs.Script\Description\DotNet\FunctionAssemblyLoadContext.cs:line 392 FunctionAssemblyLoadContext.Load() AssemblyLoadContext.ResolveUsingLoad() AssemblyLoadContext.Resolve() JsonPropertyInfo.GetPolicies() JsonPropertyInfo<KeyVaultSecretReference>.Initialize() JsonClassInfo.CreateProperty() JsonClassInfo.CreatePropertyInfoForClassInfo() new JsonClassInfo() JsonSerializerOptions.GetOrAddClass() JsonSerializerOptions.GetOrAddClassForRootType() ReadStack.Initialize() JsonSerializer.ReadCore<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureKeyVault.KeyVaultSecretReference>() JsonSerializer.Deserialize<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureKeyVault.KeyVaultSecretReference>() JsonSerializer.Deserialize<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureKeyVault.KeyVaultSecretReference>() AzureKeyVaultKeyValueAdapter.<ProcessKeyValue>d__3.MoveNext() AsyncMethodBuilderCore.Start<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureKeyVault.AzureKeyVaultKeyValueAdapter.<ProcessKeyValue>d__3>() AsyncTaskMethodBuilder<IEnumerable<KeyValuePair<string, string>>>.Start<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureKeyVault.AzureKeyVaultKeyValueAdapter.<ProcessKeyValue>d__3>() AzureKeyVaultKeyValueAdapter.ProcessKeyValue() AzureAppConfigurationProvider.<ProcessAdapters>d__26.MoveNext() AsyncMethodBuilderCore.Start<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<ProcessAdapters>d__26>() AsyncTaskMethodBuilder<IEnumerable<KeyValuePair<string, string>>>.Start<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<ProcessAdapters>d__26>() AzureAppConfigurationProvider.ProcessAdapters() AzureAppConfigurationProvider.<SetData>d__25.MoveNext() AsyncMethodBuilderCore.Start<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<SetData>d__25>() AsyncTaskMethodBuilder.Start<Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<SetData>d__25>() AzureAppConfigurationProvider.SetData() AzureAppConfigurationProvider.<LoadAll>d__20.MoveNext() AsyncTaskMethodBuilder<VoidTaskResult>.AsyncStateMachineBox<AzureAppConfigurationProvider.<LoadAll>d__20>.ExecutionContextCallback() ExecutionContext.RunInternal() AsyncTaskMethodBuilder<VoidTaskResult>.AsyncStateMachineBox<AzureAppConfigurationProvider.<LoadAll>d__20>.MoveNext() AsyncTaskMethodBuilder<VoidTaskResult>.AsyncStateMachineBox<AzureAppConfigurationProvider.<LoadAll>d__20>.MoveNext() AwaitTaskContinuation.RunOrScheduleAction() Task.RunContinuations() Task.FinishContinuations() Task.FinishStageThree() Task.FinishStageTwo() Task.ExecuteWithThreadLocal() Task.ExecuteEntryUnsafe() Task.ExecuteFromThreadPool() ThreadPoolWorkQueue.Dispatch() _ThreadPoolWaitCallback.PerformWaitCallback() [Native to Managed Transition]

Referencing original logged issue:
dotnet/runtime#52845

@arkiaconsulting
Copy link

As a side note, bumping Microsoft.NET.Sdk.Functions from 3.0.11 to 3.0.12 drops System.Text.Encodings.Web.dll from the publish folder.

<ItemGroup>
	<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
	<PackageReference Include="System.Text.Json" Version="5.0.2" />
</ItemGroup>

=> System.Text.Encodings.Web.dll present

<ItemGroup>
	<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.12" />
	<PackageReference Include="System.Text.Json" Version="5.0.2" />
</ItemGroup>

=> System.Text.Encodings.Web.dll not present

@notaroobob
Copy link
Author

notaroobob commented May 28, 2021

Already went down that path last week. It's either something in Azure App Config or System.Text.Json or the Functions Run time itself, but I've got stay focused on shipping workable code so i can't keep digging into which part of the system is still thinking they need System.Text.Encodings.Web 5.0.0 during Function Start Up. You'll see I think in my referenced issue where I found a December issue where certain libraries were accidentally compiled with Run Time dependencies versus those from the imported packages.

Life is good
Microsoft.Azure.AppConfiguration.AspNetCore 4.4.0
Microsoft.Net.Sdk.Functions 3.0.12
System.Text.Encodings.Web 5.0.1
System.Text.Json 5.0.1

Life is Bad
Microsoft.Azure.AppConfiguration.AspNetCore 4.4.0
Microsoft.Net.Sdk.Functions 3.0.12
System.Text.Encodings.Web 5.0.1
System.Text.Json 5.0.2

@v-anvari v-anvari self-assigned this May 31, 2021
@v-anvari
Copy link

Hi @notaroobob , Thank you for your feedback! We will investigate this further and update you with the findings.

@v-anvari
Copy link

v-anvari commented Jun 7, 2021

Hi @notaroobob , Apologies for the delayed response, I discussed this scenario with the team and they confirmed that the 5.x.x version of system.text,json will no longer be supported with the version 3 of azure functions, and it is recommended to use the worker model instead.

Let us know if any further queries

@notaroobob
Copy link
Author

Well. that's certainly a bummer considering Durable Functions aren't supported on the worker model.

To be blunt, Microsoft has left developers in limbo until November 2021 (dot net 6, re-unifying the runtimes with developer expectations). Dependabot keeps telling me about all of these upgrades that I should be taking advantage of but I have to keep declining as most things aren't exactly FaaS or PaaS compatible without modification.

Not mad enough to leave the stack, but I've been burned by the Extensions libraries, Entity Framework, and now System.Text.Json while tryin to stay lean and mean on the Azure platform.

@v-anvari
Copy link

Hi @notaroobob , Apologies for the delay, I was internally checking with the team with all the possibilities here. If you want to use durable functions, then you will have to downgrade the system.text.json to 3.x.x. From 5.x.x, you will have to use the worker model which do not support the durable functions.

@v-anvari
Copy link

Closing this issue as this is by-design, Please feel free to open a feature request here - https://feedback.azure.com/forums/355860-azure-functions

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

No branches or pull requests

3 participants