Azure / azure-cosmos-dotnet-v3

.NET SDK for Azure Cosmos DB for the core SQL API
MIT License
741 stars 494 forks source link

Logic Apps Cosmos DB Connector: Issue with date values when function convertFromUtc(utcNow(),'AUS Eastern Standard Time') is used. #4290

Closed philipthomas-MSFT closed 7 months ago

philipthomas-MSFT commented 9 months ago

Background

Based on an incident in the Logic Apps queue where CX is using convertFromUtc.

Incident

ICM # 451698957

Proposed fix

Similar to an issue on BLOB connector,

BLOB Jsonconverter: Converters.cs - Repos (visualstudio.com)
 else if (!string.IsNullOrEmpty(contentType) && contentType.IsContentJsonMediaType())
                {
                    if (Converters.PreserveJsonContentOnRead)
                    {
                        bufferedMemoryStream.Position = 0;

                        return await Converters.flowJsonFormatter
                            .ReadFromStreamAsync(
                                type: typeof(JToken),
                                readStream: bufferedMemoryStream,
                                content: null,
                                formatterLogger: null)
                            .ConfigureAwait(continueOnCapturedContext: false) as JToken;
                    }

Cosmos Read document: ReadDocumentOperation.cs - Repos (visualstudio.com)
 var operationResponse = new ReadDocumentOperationResponse
            {
                ActivityId = itemResponse.ActivityId,
                ETag = itemResponse.ETag,
                Id = itemResponse.Resource["id"].Value<string>(),
                Content = itemResponse.Resource,
                RequestCharge = itemResponse.RequestCharge,
                Timestamp = DateTimeOffset
                    .FromUnixTimeSeconds(long.Parse(itemResponse.Resource["_ts"].Value<string>()))
                    .UtcDateTime,
            };

            return new ServiceOperationResponse(
                body: JToken.FromObject(operationResponse),
                statusCode: itemResponse.StatusCode);

Repo

users/philipthomas/4290_451698957_convertFromUtc_incident_cosmos_db_connector

Dependency upgrades

Must haves

philipthomas-MSFT commented 8 months ago

This is blocked because there is no actionable work for the .NET SDK team. Logic Apps is currently working on finding the root cause. I will keep this in blocked for another week, then I will close this.