I've just upgraded an Azure Function App from .NETCoreApp2.2 to .NETCoreApp3.1. When running the function locally (started from VS2019 16.4.0) I see that the JsonProperty attributes which are defined on my model classes are not respected.
public class Movie
{
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("episode_id")]
public int Episode { get; set; }
[JsonProperty("release_date")]
public string ReleaseDate { get; set; }
}
Repo to repoduce: https://github.com/marcduiker/xebia-webinar-week-azurefunctions
Branch: development-v3
Do a GET to http://localhost:7071/api/movies
The JsonProperty attributes are respected.
[
{
"title": "A New Hope",
"episode_id": 4,
"release_date": "1977-05-25"
},
...
]
The JsonProperty attributes are not respected. No errors are shown.
[
{
"title": "A New Hope",
"episode": 0,
"releaseDate": null
},
...
]
@fabiocav mentioned that a workaround would be to set the App Setting FUNCTIONS_V2_COMPATIBILITY_MODE=true. This indeed works. 馃憤
Azure Functions Core Tools (3.0.1975 Commit hash: faab364ffc9b9bbaaac212d061691663624d8d4)
Function Runtime Version: 3.0.12930.0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
@fabiocav & team -- Visual Studio and func core tools are still on 3.0.12930.0. Developing locally, JsonProperty is not respected. Then upon release, it suddenly is. This is causing big challenges in the development process. Any idea when VS or func core tools will be updated??
@fabiocav & team -- any information or updates available here? VS 16.4.4 was just put out today and it still has 3.0.12930.0. This makes it very challenging to develop solutions in VS that run the same as they do in Azure, as Json serialization works differently.
Most helpful comment
@fabiocav & team -- Visual Studio and func core tools are still on 3.0.12930.0. Developing locally, JsonProperty is not respected. Then upon release, it suddenly is. This is causing big challenges in the development process. Any idea when VS or func core tools will be updated??