在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.