Stop/Kill a running Azure Function

17,271

Solution 1

You have the ability to simply restart the Function App site, which will kill any functions (Function App Settings > Go To App Service Settings > Restart).

If you are running on a dynamic plan, please make sure you have upgraded to the latest version of the runtime, as a timeout feature is now in effect and will prevent functions from executing indefinitely.

Solution 2

For automation purposes, you can use the Azure CLI 2.0 (local azure shell) which makes this so much easier than clicking around in the portal blades.

This also works in the portal cloud shell if so desired.

Option #1: Restart Entire Function App (via Azure CLI)

az functionapp restart --name <functionappName> --resource-group <resourceGroup>

You can also restart the function app by killing the running w3wp.exe process - there is a watchdog that will automatically restart it.

Option #2: Restart IIS Worker Process (via Powershell)

@powershell kill -name w3wp

Kudu will allow you to do this manually via Debug Console and entering the command above or clicking thru Process Explorer->Properties->Kill.

Note: Killing the IIS worker process is all that is required as any spawned child processes will also be terminated (dotnet.exe, node, etc.)

Solution 3

This is the order of clicks starting from the portal home page to restart a function app in azure:

-> Function Apps (Found on the very left-hand sidebar, or on dashboard)

-> yourFunction (mine is called 'myFunction')

-> Platform Features (found near the top right of the screen)

-> All Settings (found under the General Settings section)

-> Restart (found near the top of the screen)

Solution 4

It seems the portal has been updated as I couldn't find the Restart button using the given instructions.

As of 17/7/2020 you can restart a Function app by navigating to the App Service page then clicking the Restart button which is found in the Toolbar:

enter image description here

Share:
17,271
Chrono
Author by

Chrono

Updated on June 15, 2022

Comments

  • Chrono
    Chrono almost 2 years

    I noticed I have multiple functions running but never ending because they never get to the context.done() call. (This is a NodeJS function).

    How can I stop these running functions without having to delete the entire function?

    • Disabling the function in the Manage tab prevents it from starting more, but doesn't end existing instances.
    • Kudu doesn't give me access to TASKKILL.
  • frictionlesspulley
    frictionlesspulley over 7 years
    I am updated to the latest 1.0 version and I am getting instances of executions that havent stopped for some time.. stopping - starting the site / restarting the site or even killing the processes from kudu interface did not make the instances go away
  • Fabio Cavalcante
    Fabio Cavalcante over 7 years
    @frictionlesspulley can you have a new question with more details about what you're seeing? When you say "instances" are you referring to individual function executions?
  • frictionlesspulley
    frictionlesspulley over 7 years
    I created a question with screenshots of the monitor log here stackoverflow.com/q/40686039/314763