Azure 函数:使计划 cron 成为 function.json 中的变量
Azure function: make schedule cron a variable in function.json
我有一个 Azure 函数。对于代码,我只有 init.py 和 function.json.
function.json 就像下面这样:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 1 */12 * * *"
}
]
}
是否可以将时间表中的“12”设为变量(例如称为 IntervalVariable)并从 init.py 获取它?
这样就变成了
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 1 */{IntervalVariable} * * *"
}
]
}
我刚刚意识到这可以通过 %IntervalVariable% 轻松完成,并在 Azure 应用程序设置中添加键值对。
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 1 */%IntervalVariable% * * *"
}
]
}
然后添加
key: IntervalVariable
value: 12
在 Azure 函数应用程序设置中。
我有一个 Azure 函数。对于代码,我只有 init.py 和 function.json.
function.json 就像下面这样:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 1 */12 * * *"
}
]
}
是否可以将时间表中的“12”设为变量(例如称为 IntervalVariable)并从 init.py 获取它?
这样就变成了
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 1 */{IntervalVariable} * * *"
}
]
}
我刚刚意识到这可以通过 %IntervalVariable% 轻松完成,并在 Azure 应用程序设置中添加键值对。
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "timer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 1 */%IntervalVariable% * * *"
}
]
}
然后添加
key: IntervalVariable
value: 12
在 Azure 函数应用程序设置中。