[英]Programmatically Stop an Azure function and start it back again
I have an azure function that reads messages from a service bus queue and sends a request to an API with the message. 我有一个azure函数,该函数从服务总线队列中读取消息,并使用消息将请求发送到API。 This works fine.
这很好。
Sometimes the API may be unreachable due to factors not in our control. 有时,由于我们无法控制的因素,API可能无法访问。 Is there a way to stop the Azure function from recieving updates from the queue or stop execution altogether till it is restarted ideally via an api call or via an environment variable ?
有没有一种方法可以停止Azure函数从队列中接收更新,或者完全停止执行,直到通过api调用或通过环境变量将其理想地重新启动为止?
Yes, you can use an environment variable. 是的,您可以使用环境变量。 For example, if you have an environment variable named
TIMER_DISABLED
, you can reference that setting in the disabled
function property like so: 例如,如果您有一个名为
TIMER_DISABLED
的环境变量,则可以在disabled
函数属性中引用该设置,如下所示:
{
"disabled": "TIMER_DISABLED",
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "*/5 * * * * *"
}
]
}
The function will then only be enabled if the app setting value is truthy, eg equal to 1 or "true". 然后,仅在应用程序设置值为“真”(例如等于1或“真”)时才启用该功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.