简体   繁体   English

如何使用计时器触发器将时区传递给 Azure 函数

[英]How to pass timezone to Azure function with timer trigger

I created an azure function that I need to run at 11 AM EST time.我创建了一个需要在美国东部标准时间上午 11 点运行的 azure 函数。 I understand the timer triggers use UTC however is there a way to pass in 11 AM to the run function for readability purposes?我知道计时器触发器使用 UTC 但是有没有办法将上午 11 点传递给运行函数以提高可读性?

For example here is my run method, is it possible to pass 11 AM where the X sits and specify a timezone?:例如,这是我的运行方法,是否可以通过 X 所在的上午 11 点并指定时区?:

public static void Run([TimerTrigger("0 0 X * * *")]TimerInfo myTimer, TraceWriter log)

Azure Function based on Web app sandbox.基于 Web 应用沙箱的 Azure Function。 Web app need you to set the timezone in env settings first. Web 应用程序需要您首先在 env 设置中设置时区。 The timetrigger attribute is the declaration part of the function. timetrigger 属性是函数的声明部分。 The environment variables will be checked here.这里将检查环境变量。 If you do not set the environment variables about the time zone in advance, it will be processed according to the default UTC time.如果没有提前设置时区的环境变量,会按照默认的UTC时间处理。

The env variable comes from different place when run on local and run on azure.在本地运行和在 azure 上运行时,env 变量来自不同的地方。

For example, if you want to set EST time.例如,如果要设置 EST 时间。

On local, you need to set it in local.settings.json.在本地,您需要在 local.settings.json 中进行设置。 like this:像这样:

{
    "IsEncrypted": false,
    "Values": {
      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
      "FUNCTIONS_WORKER_RUNTIME": "dotnet",
      "WEBSITE_TIME_ZONE": "US Eastern Standard Time"
    }
}

On Azure, set the time zone in this place(dont forget to save the changes):在 Azure 上,在此位置设置时区(不要忘记保存更改):

在此处输入图片说明

在此处输入图片说明


From this doc , EST = GMT - 5. So in your case, if you are in default time zone, you can set the CRON as 0 0 6 * * * .这个 doc , EST = GMT - 5. 所以在你的情况下,如果你在默认时区,你可以将 CRON 设置为0 0 6 * * * Since the hour cannot be negative.由于小时不能为负。 So it is valid for your situation, but not necessarily applicable to other situations.所以它对你的情况有效,但不一定适用于其他情况。 I suggest you use the method I recommended at the beginning.我建议你使用我一开始推荐的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure function 定时器触发器 - Azure function timer trigger 如何从计时器触发器获取 azure 函数运行的主机名? - How to get the hostname for where the azure function run from timer trigger? 从 Azure 计时器触发器函数访问位于 Azure Blob 中的文件 - Accessing a file located in Azure Blob, from Azure Timer Trigger Function Azure Function Cronn 表达式在 Azure 定时器触发器中不起作用 - Azure Function Cronn Expression not working in Azure Timer Trigger 是否可以通过顺序执行来执行 Azure 函数定时器触发器? - Is it possible to execute Azure function Timer trigger with Sequential Execution? Azure函数输出服务总线绑定从计时器触发器 - Azure Function Output Service Bus Binding From Timer trigger Azure 函数计时器触发器是否可以迭代容器或目录中的所有 blob? - Can an Azure Function timer trigger iterate all blobs in a container or directory? 序列中的 Azure 计时器触发函数 - Azure Timer Trigger Functions in Sequence 如何在Data Factory管道中将路由传递到Azure函数(C#)http触发器? - How to pass a route to Azure function (C#) http trigger in Data Factory pipeline? 如何在 Azure 函数 eventthub 触发器中处理 CancellationToken - How to handle CancellationToken in Azure function eventhub trigger
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM