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 * * * * *.
这应该总结这里给出的其他答案:
配置本地设置
{
"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
Application settings Add new setting schedule为键和*/30 * * * * *值save左上方| 归档时间: |
|
| 查看次数: |
1379 次 |
| 最近记录: |