简体   繁体   中英

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. This works fine.

Sometimes the API may be unreachable due to factors not in our control. 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 ?

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:

{
  "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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM