azure-webjobs-sdk-extensions
azure-webjobs-sdk-extensions copied to clipboard
CosmosDBTrigger Alters DateTimeOffset Format in Azure Function Isolated Process
I'm encountering an issue with the CosmosDBTrigger in an Azure Function using the isolated process model. When documents are triggered by changes in a Cosmos DB collection, the CosmosDBTrigger seems to alter the format of DateTimeOffset fields in the JSON payload.
Repro steps
Set up an Azure Function with a CosmosDBTrigger to monitor changes in a Cosmos DB collection.
public class TriggerFunction(ILoggerFactory loggerFactory)
{
private readonly ILogger _logger = loggerFactory.CreateLogger<Function>();
[Function("TriggerFunction")]
public void Run([CosmosDBTrigger(
databaseName: "my-database",
containerName: "my-container",
Connection = "ConnectionStrings:Cosmos",
LeaseContainerName = "leases",
StartFromBeginning = true,
LeaseContainerPrefix = "my-",
CreateLeaseContainerIfNotExists = true)] string input)
{
_logger.LogInformation("Migration {input}", input);
}
}
- Insert a document into the Cosmos DB collection:
{
"id": "1",
"TransactionDate": "2023-07-04T12:00:00+00:00"
}
- The CosmosDBTrigger function receives:
{
"id": "1",
"TransactionDate": "2023-07-04T14:00:00+02:00"
}
Expected behavior
The CosmosDBTrigger should pass the document as-is without altering the format or values.
Actual behavior
The date field in the JSON document is modified.
Known workarounds
none.
Related information
- Azure Function 4.x - isolated process
- Language C#
- Packages: Microsoft.Azure.Functions.Worker, Version="1.22.0" Microsoft.Azure.Functions.Worker.Extensions.CosmosDB, Version="4.9.0" Microsoft.Azure.Functions.Worker.Extensions.Http, Version="3.2.0" Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore, Version="1.3.2" Microsoft.Azure.Functions.Worker.Sdk, Version="1.17.2" Microsoft.ApplicationInsights.WorkerService, Version="2.22.0" Microsoft.Azure.Functions.Worker.ApplicationInsights, Version="1.2.0"