question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IANA timezone style doesn't work on Windows dotnet 6.

See original GitHub issue

Investigative information

I’m using a Windows function v4 using dotnet 6 on consumption tier in Japan East. Our code uses TimeZoneInfo with IANA style, but the code throws System.TimeZoneNotFoundException.

Repro steps

Create a new function on the portal. And create a new HttpTrigger function like follows:

#r "Newtonsoft.Json"
using System;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");
    //var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
    var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Asia/Tokyo");
    log.LogInformation($"{timeZone}");

    string name = req.Query["name"];

    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
    dynamic data = JsonConvert.DeserializeObject(requestBody);
    name = name ?? data?.name;

    string responseMessage = string.IsNullOrEmpty(name)
        ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);
}

Hit to “Run” the above code.

Expected behavior

It should be successfully finished.

Actual behavior

It throws a following exception.

2021-11-30T15:10:21.022 [Error] Executed 'Functions.HttpTrigger1' (Failed, Id=91fd9fd5-5b20-4a42-92cf-42bdf78de402, Duration=16ms)The time zone ID 'Asia/Tokyo' was not found on the local computer.

Dotnet 6 supports both IANA and Windows time zone style. So the code above should be fine. https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6/

Known workarounds

If we use TimeZoneConverter library, it accepts IANA style even on Windows.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kshyjucommented, Mar 4, 2022

Hi @daigok Thanks for sharing the repro information. This issue is not specific to azure functions. You will experience the same issue if you try your code in an aspnet core web api (net 6) and deploy to azure. Let me check with the team to determine whether this is a platform issue or an issue with the API itself.

cc @pragnagopa @fabiocav

0reactions
msftbot[bot]commented, Mar 18, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Time Zone Identifiers not supported in .NET 6 ...
NET 6 we should be able to use both IANA and Windows Time Zone identifier formats. However this doesn't work in Blazor WASM...
Read more >
What's up with TimeZoneInfo on .NET 6? (Part 1)
NET : it uses TimeZoneInfo as a data source, and basically adapts it into a Noda Time representation. The TZDB source implements the...
Read more >
Date, Time, and Time Zone Enhancements in .NET 6
NET Core came out, this problem was exacerbated because Windows time zone data was not available on non-Windows systems like Linux and macOS....
Read more >
Cross-platform Time Zones with .NET Core - .NET Blog
Once you have it installed, you are able to work with different operating system Time Zone providers in a uniform way.
Read more >
Converting times between time zones
Learn to convert times between from one time zone to another in .NET ... If the date and time value doesn't represent the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found