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

C# V3: Newtonsoft support #1618

Closed
topres opened this issue Jun 8, 2020 · 3 comments
Closed

C# V3: Newtonsoft support #1618

topres opened this issue Jun 8, 2020 · 3 comments

Comments

@topres
Copy link

topres commented Jun 8, 2020

It appears that V3 of azure functions is using either System.Text.Json or another serializer by default when model binding in azure functions.

I have the following function:

    [FunctionName("Test")]
    public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "test")] Request request)
    {
        return new OkResult();
    }

    public class Request
    {
        public string SerialNumber { get; }

        public Request(string serialNumber)
        {
            SerialNumber = SerialNumber;
        }
    }

I have tried using the same extension methods used when doing this in MVC projects, like this:

public class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder)
    {
        builder
            .Services
            .AddMvcCore()
            .AddNewtonsoftJson();
    }
}

I am not looking for solutions to work with System.Text.Json, our team has decided that we want to use Newtonsoft for various reasons.

We would just very much like to use the built in model binding of the framework, to avoid taking in a HttpRequest and deserializing for each function.

Question
How do I use Newtonsoft in Dotnet Core Azure Functions V3?

@v-anvari v-anvari self-assigned this Mar 17, 2021
@v-anvari
Copy link

Hi @topres , The ability to customize the deserializer stack is not a possible feature for now.

Closing this issue, please feel free to reach back to us in case of any further queries related to this issue

@v-anvari v-anvari removed their assignment Mar 22, 2021
@Sti2nd
Copy link

Sti2nd commented Jun 16, 2021

Created a post on UserVoice. https://feedback.azure.com/forums/355860-azure-functions/suggestions/43644627-allow-to-use-newtonsoft-for-all-model-binding

I assume UserVoice is the correct channel since you closed the feature request here, @v-anvari ?

@v-anvari
Copy link

Hi @Sti2nd , Yes, That would be the right channel to raise a feedback or feature.

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