@Matthew Villarreal Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I see that you are having trouble terminating an Azure orchestration function instance via API and is receiving a 404 error. You are looking for alternative ways to terminate the instance.
I am sharing 2 more ways how you can terminate the Durable Function instance:
Approach 1:
If you have an orchestration instance that is taking too long to run, or you just need to stop it before it completes for any reason, you can terminate it.
The two parameters for the terminate API are an instance ID and a reason string, which are written to logs and to the instance status.
[FunctionName("TerminateInstance")]
public static Task Run(
[DurableClient] IDurableOrchestrationClient client,
[QueueTrigger("terminate-queue")] string instanceId)
{
string reason = "Found a bug";
return client.TerminateAsync(instanceId, reason);
}
A terminated instance will eventually transition into the Terminated
state. However, this transition will not happen immediately. Rather, the terminate operation will be queued in the task hub along with other operations for that instance. You can use the instance query APIs to know when a terminated instance has actually reached the Terminated
state.
Approach 2:
You can also terminate an orchestration instance directly, by using the func durable terminate
command in Core Tools.
The durable terminate
command takes the following parameters:
-
id
(required): ID of the orchestration instance to terminate. -
reason
(optional): Reason for termination. -
connection-string-setting
(optional): Name of the application setting containing the storage connection string to use. The default isAzureWebJobsStorage
. -
task-hub-name
(optional): Name of the Durable Functions task hub to use. The default isDurableFunctionsHub
. It can also be set in host.json, by using durableTask:HubName.
The following command terminates an orchestration instance with an ID of 0ab8c55a66644d68a3a8b220b12d209c:
func durable terminate --id 0ab8c55a66644d68a3a8b220b12d209c --reason "Found a bug"
Fore more information, please refer this article.
Hope this helps.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.