Created
October 20, 2022 21:06
-
-
Save ealsur/d42abe66f04c092285452e7b4d5c5145 to your computer and use it in GitHub Desktop.
Azure Functions custom serializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly: FunctionsStartup(typeof(FunctionApp1.Startup))] | |
namespace FunctionApp1 | |
{ | |
public class Startup : FunctionsStartup | |
{ | |
public override void Configure(IFunctionsHostBuilder builder) | |
{ | |
builder.Services.AddSingleton<ICosmosDBSerializerFactory, MyCosmosDBSerializerFactory>(); | |
} | |
} | |
public class MyCosmosDBSerializerFactory : ICosmosDBSerializerFactory | |
{ | |
public CosmosSerializer CreateSerializer() | |
{ | |
var options = new JsonSerializerOptions(); | |
// return a custom implementation of CosmosSerializer | |
return new CosmosSystemTextJsonSerializer(options); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment