Adding my answer as the accepted answer did not work for me.
The idea is the same, that Cosmos uses Newtonsoft internally for serialization purposes and if you are using System.Text.Json adding the attribute to change the property name to "id" on serialization will not work.
There is a "UseSystemTextJsonSerializerWithOptions" property in CosmosClientOptions that we can set with an object of type JsonSerializerOptions. Just using this has fixed this error for me.
CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
UseSystemTextJsonSerializerWithOptions = new JsonSerializerOptions()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
PropertyNameCaseInsensitive = true
}
};
var cosmosClient = new CosmosClient(connectionString: appSettings.CosmosDbConnectionString, cosmosClientOptions);