Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Locale Settings in Azure Functions
[FunctionName(nameof(Default))]
public static async Task<IActionResult> Default(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "locale/default")] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
var body = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(body);
var date = (string)data.date;
var converted = DateTimeOffset.TryParse(date, out DateTimeOffset result)
? result
: DateTimeOffset.MinValue;
return (ActionResult)new OkObjectResult($"Input: {converted:O}");
}
[FunctionName(nameof(EnAu))]
public static async Task<IActionResult> EnAu(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "locale/en-au")] HttpRequest req,
ILogger log)
{
// Change the culuture of the thread currently running
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-AU");
log.LogInformation("C# HTTP trigger function processed a request.");
var body = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(body);
var date = (string)data.date;
var converted = DateTimeOffset.TryParse(date, out DateTimeOffset result)
? result
: DateTimeOffset.MinValue;
return (ActionResult)new OkObjectResult($"Input: {converted:O}");
}
[FunctionName(nameof(KoKr))]
public static async Task<IActionResult> KoKr(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "locale/ko-kr")] HttpRequest req,
ILogger log)
{
// Change the culuture of the thread currently running
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("ko-KR");
log.LogInformation("C# HTTP trigger function processed a request.");
var body = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(body);
var date = (string)data.date;
var converted = DateTimeOffset.TryParse(date, out DateTimeOffset result)
? result
: DateTimeOffset.MinValue;
return (ActionResult)new OkObjectResult($"Input: {converted:O}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.