I am running an HTTP-Triggered Azure Durable Function with a nested orchestrator structure. A single execution of the function can run for multiple hours and make hundreds of database operations.
During development and testing, I am running the function locally in my VS Code [MacOS] in debugging mode. In order to stop the process from running, I simply hit Ctrl + C to kill the process.
The problem: When I restart the debugger, the function continues where it left off and executes extremely long-running processes. I am unable to figure out how to fully stop the previously started processes. I can tell they are running by the logs I see in my terminal.
When starting an HTTP Triggered Function, I get the "statusQueryGetUri"
and "terminatePostUri"
which I would usually use to stop the function, however I have no idea which execution is currently running, and I am not aware of how I could retrieve the ID which would allow me to terminate the run which is still active.
This is what my launch.json file looks like:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start"
}
]
}
My function is connected to my dev database and to the dev blob storage.
azure-functions==1.17.0
azure-functions-durable==1.2.6
VS Code: Version: 1.90.2
OS: Darwin arm64 23.3.0
I tried:
ps aux | grep python
then kill -9 ID
I am expecting:
I am expecting to start my debugger and see my azure function idling until I start the HTTP trigger via postman. Then when I run a function but stop it again by killing the terminal or process, I am expecting it to not continue the next time I start the debugger again.
terminatePostUri
of your function.You can get the InstanceID of the function from terminatePostUri.
http://localhost:7071/runtime/webhooks/durabletask/instances/<Instance_ID>/terminate?reason={text}&taskHub=TestHubName&connection=Storage&code=rzKXAu_HfN3-JqjaYvOzZon5ACBt8Ew7lVvou6zQNMjDAzFuFAtHMw==
terminatePostUri
by updating the reason in the URI, it stops the function execution using the command:func durable terminate --id <Instance_ID> --reason <reason to terminate>
Disconnect the debugger to stop the function in the Debug bar.
To completely stop a locally running Azure Function, you should stop the process that is running the function in the Activity Monitor on macOS.
func host start --debug
and use Ctrl+C
to stop running the function:References: