简体   繁体   English

动态计划触发器 Azure 逻辑应用

[英]Dynamic schedule trigger Azure Logic Apps

I am creating a scheduler implementation for tasks, where in a certain API needs to be called at a date time dictated by the task itself.我正在为任务创建一个调度程序实现,其中某个 API 需要在任务本身规定的日期时间调用。 I looked at the Azure Logic Apps service, and looks like it could work.我查看了 Azure 逻辑应用服务,看起来它可以工作。 I created a flow "When Http Request is Recieved"... This flow then calls the API that we eventually needs to be called at the date time passed to it ( "when http request is recieved" flow).我创建了一个流程“当收到 Http 请求时”......然后此流程调用 API,我们最终需要在传递给它的日期时间调用它(“当 Z80791B3AE7002CB88C246876D9FAAA14FZ 请求被接收时)。

Is summary a C# app calls the logic flow, and passes the date time and request body to logic apps.总结一个 C# 应用程序调用逻辑流,并将日期时间和请求正文传递给逻辑应用程序。 Logic apps gets triggered.逻辑应用被触发。 But then uses date time to later call the API that it is required to call但是然后使用日期时间稍后调用它需要调用的API

Example: Logic App Run 1 Time: Aug-4-2020 12:00 am Data: {"Object":"somevalue"}示例:逻辑应用运行 1 时间:2020 年 8 月 4 日上午 12:00 数据: {"Object":"somevalue"}

Logic App Run 2 Time: Aug-9-2020 12:00 am Data: {"Object":"some different value"}逻辑应用运行 2 时间:2020 年 8 月 9 日上午 12:00 数据: {"Object":"some different value"}

So, is there a way when triggering logic apps through http trigger, I could also pass the datetime value that azure logic uses to schedule the API call那么,有没有办法在通过 http 触发器触发逻辑应用程序时,我还可以传递 azure 逻辑用来安排 API 调用的日期时间值

For this requirement, you can use " Delay until " action in logic app.对于此要求,您可以在逻辑应用中使用“ 延迟直到”操作。 Pass the datetime value(in my screenshot the field named datetime ) in the request body when request the "When Http Request is Recieved" flow.当请求“收到 Http 请求时”流时,在请求正文中传递日期时间值(在我的屏幕截图中名为datetime的字段)。 And then create a "Delay until" action, put the value into the Timestamp box of it.然后创建一个“延迟到”动作,将值放入它的Timestamp框中。

在此处输入图像描述

Please pay attention to the format of the datetime, the format should be YYYY-MM-DDThh:mm:ssZ .请注意日期时间的格式,格式应为YYYY-MM-DDThh:mm:ssZ

After the "Delay until" action, call the api which you want.在“延迟到”操作之后,调用您想要的 api。

By the way, you may need to notice the time zone of your datetime.顺便说一句,您可能需要注意日期时间的时区。 It seems the "Delay until" action use UTC time, so if you are not in UTC(+0) time zone, you need to convert the time zone of your datetime.似乎“延迟直到”操作使用 UTC 时间,因此如果您不在 UTC(+0) 时区,则需要转换日期时间的时区。 You can use convertTimeZone() method or addHours() method.您可以使用convertTimeZone()方法或addHours()方法。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM