Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop/Kill a running Azure Function

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.
like image 690
Chrono Avatar asked Oct 08 '16 17:10

Chrono


People also ask

How do you stop an azure function?

The recommended way to disable a function is with an app setting in the format AzureWebJobs. <FUNCTION_NAME>. Disabled set to true . You can create and modify this application setting in a number of ways, including by using the Azure CLI and from your function's Overview tab in the Azure portal.

How to Kill Azure function locally?

Use command line to kill the process. Right click on project> Show in Local Terminal> Terminal, input TASKKILL /IM func.exe /T /F to kill func.exe . Run function in terminal hence we can terminate it.

What is durable Azure function?

Durable Functions is an extension of Azure Functions that lets you write stateful functions in a serverless compute environment. The extension lets you define stateful workflows by writing orchestrator functions and stateful entities by writing entity functions using the Azure Functions programming model.

How Azure functions are executed?

Trigger based executions Azure Functions get executed based on the configured triggers. It supports various triggers like HTTP Triggers, Queue Trigger, Event Hub Trigger and more. Being as a trigger-based service, it run on demand.


Video Answer


2 Answers

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.

like image 194
Fabio Cavalcante Avatar answered Sep 21 '22 23:09

Fabio Cavalcante


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.)

like image 39
SliverNinja - MSFT Avatar answered Sep 21 '22 23:09

SliverNinja - MSFT