Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
413 stars 180 forks source link

TimeZoneInfo.FindSystemTimeZoneById discrepancy in .Net 8 based Web API deployed as Web App on Linux #2363

Closed ranjeetkpGit closed 5 months ago

ranjeetkpGit commented 5 months ago

Description

Hi, I am using following in .Net 6 based Web API deployed as Web App on Linux and it works fine TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time") and TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")

When we migrated to .Net 8 based Web API deployed as Web App on Linux it returns nothing in both the methods.

Steps to reproduce

  1. Deploy .Net 6 based Web API as Web App on Linux with TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time") and TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"). It will return 'Pacific Daylight Time' from first and 'Japan Standard Time' from second method

  2. Now deploy .Net 8 based Web API as Web App on Linux with TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time") and TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"). It will return nothing from both the methods

Deployment using Azure Devops Release- image

kshyju commented 5 months ago

@ranjeetkpGit By "function deployed as Web App", did you mean using the aspnet core integration model on a .NET 8 isolated model? If not, please elaborate what you meant by that.

I could not reproduce the error you are mentioning, when using the code snippet you mentioned locally and when deploying to Azure Linux (consumption) platform. See https://shkr-net8-gh2363-lin-c-20240322.azurewebsites.net/api/timezone (Note: This test app link will expire on 3/29/2024). The method (TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")) is returning a non null TimeZoneInfo object.

Below is the source code I used for my function. You can see the source code of the full app here

[Function("TimeZone")]
public IActionResult GetTimeZone([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
    return new OkObjectResult(new
    {
        RuntimeInformation.FrameworkDescription,
        RuntimeInformation.OSDescription,
        TimeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"),
        TimeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")
    });
}
ranjeetkpGit commented 5 months ago

@kshyju extremely sorry for mistake. This is not for Azure function but .Net 8 Web API. Editing and moving to app-service-announcements

https://github.com/Azure/app-service-announcements/issues/465

Dolphinsimon commented 5 months ago

The app-service-announcements is for team announcements only.