更改从Visual Studio发布的Azure for Azure功能的计时器间隔

Mat*_*und 4 timer azure azure-functions

我有一个功能应用程序与以下代码

public static void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, TraceWriter log)
Run Code Online (Sandbox Code Playgroud)

这每5秒执行一次我的功能.在制作中我希望间隔为30秒.将功能发布到Azure后,它每5秒运行一次.

在功能设置的"集成"页面的顶部,有一条消息"您的应用程序当前处于只读模式,因为您已发布了生成的函数.json.函数运行时将不会对函数.json进行更改"而且页面显示为灰色.

那么如何在开发和生产中为我的计时器功能制定不同的计划?

Mik*_*kov 10

使您的日程安排可配置.在代码中声明它如下:

[TimerTrigger("%schedule%")]
Run Code Online (Sandbox Code Playgroud)

然后schedule使用值添加名为value */5 * * * * *和production setting 的开发设置*/30 * * * * *.


Mov*_*GP0 6

这应该总结这里给出的其他答案:

配置本地设置

{
  "Values": { 
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=XXXXXXXXXX;AccountKey=XXXXXXXXXX", 
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=XXXXXXXXXX;AccountKey=XXXXXXXXXX", 
    "schedule": "*/5 * * * * *",
    "//": "put additional settings in here"
  },
  "Host": {
    "LocalHttpPort": 7071,
    "CORS": "*"
  },
  "ConnectionStrings": {
    "SQLConnectionString": "XXXXXXXXXX"
  }
}
Run Code Online (Sandbox Code Playgroud)
  • 将触发属性设置为
{
  "Values": { 
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=XXXXXXXXXX;AccountKey=XXXXXXXXXX", 
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=XXXXXXXXXX;AccountKey=XXXXXXXXXX", 
    "schedule": "*/5 * * * * *",
    "//": "put additional settings in here"
  },
  "Host": {
    "LocalHttpPort": 7071,
    "CORS": "*"
  },
  "ConnectionStrings": {
    "SQLConnectionString": "XXXXXXXXXX"
  }
}
Run Code Online (Sandbox Code Playgroud)

配置Azure

  • 转到Azure门户并转到功能,单击您的功能并选择Application settings
  • 在应用程序设置中选择 Add new setting
  • 输入schedule为键和*/30 * * * * *
  • 点击save左上方
  • 重新部署您的功能