在Azure功能中动态设置计划 [英] Dynamically set schedule in Azure Function

查看:72
本文介绍了在Azure功能中动态设置计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Azure函数具有以下function.json,其计划设置为每天9.30运行.我想要的是动态设置此json的schedule属性.当正在使用我的应用程序的客户端输入日期时,就会出现这种情况,该日期计划程序应该在该日期表上运行.

I have following function.json for my Azure function whose schedule is set to run at 9.30 daily. What I want is to dynamically set the schedule attribute of this json. This scenario arises when a client who is using my application enters date, on that date-scheduler should run.

   {
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 30 9 * * *" //Want to set dynamically
    }
  ],
  "disabled": false
}

这可能吗?

(还要注意,由于预算原因,我不想使用Azure Scheduler)

(Also note, I don't want to use Azure Scheduler due to budgeting reasons)

推荐答案

  1. 使用Kudu API更改function.json https://github.com/projectkudu/kudu/wiki/REST-API

  1. Use Kudu API to change function.json https://github.com/projectkudu/kudu/wiki/REST-API

PUT https://{functionAppName} .scm.azurewebsites.net/api/vfs/{pathToFunction.json}, 标题:如果匹配:"*", 正文:新的function.json内容

PUT https://{functionAppName}.scm.azurewebsites.net/api/vfs/{pathToFunction.json}, Headers: If-Match: "*", Body: new function.json content

然后发送请求以应用更改

Then send request to apply changes

POST https://{functionAppName} .scm.azurewebsites.net/api/functions/synctriggers

POST https://{functionAppName}.scm.azurewebsites.net/api/functions/synctriggers

或者您可以将队列触发器与"initialVisibilityDelay"消息一起使用.在这种情况下,您需要编写自己的代码以实现调度程序.

Or you can use Queue Trigger with "initialVisibilityDelay" messages. In this case you need to write your own code to implement a scheduler.

这篇关于在Azure功能中动态设置计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆