Terminate a long running operation on an Azure Kubernetes Service (AKS) cluster

Sometimes deployment or other processes running within pods on nodes in a cluster can run for periods of time longer than expected due to various reasons. While it's important to allow those processes to gracefully terminate when they're no longer needed, there are circumstances where you need to release control of node pools and clusters with long running operations using an abort command.

AKS now supports aborting a long running operation, which is currently in public preview. This feature allows you to take back control and run another operation seamlessly. This design is supported using the Azure REST API or the Azure CLI.

The abort operation supports the following scenarios:

  • If a long running operation is stuck or suspected to be in a bad state or failing, the operation can be aborted provided it's the last running operation on the Managed Cluster or agent pool.
  • If a long running operation is stuck or failing, that operation can be aborted.
  • An operation that was triggered in error can be aborted as long as the operation doesn't reach a terminal state first.

Before you begin

  • The Azure CLI version 2.40.0 or later. Run az --version to find the version, and run az upgrade to upgrade the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].

  • The aks-preview extension version 0.5.102 or later.


AKS preview features are available on a self-service, opt-in basis. Previews are provided "as is" and "as available," and they're excluded from the service-level agreements and limited warranty. AKS previews are partially covered by customer support on a best-effort basis. As such, these features aren't meant for production use. For more information, see the following support articles:

Abort a long running operation

You can use the az aks nodepool command with the operation-abort argument to abort an operation on a node pool or a managed cluster.

The following example terminates an operation on a node pool on a specified cluster by its name and resource group that holds the cluster.

az aks nodepool operation-abort --resource-group myResourceGroup --cluster-name myAKSCluster --name myNodePool 

The following example terminates an operation against a specified managed cluster its name and resource group that holds the cluster.

az aks operation-abort --name myAKSCluster --resource-group myResourceGroup

In the response, an HTTP status code of 204 is returned.

The provisioning state on the managed cluster or agent pool should be Canceled. Use the REST API Get Managed Clusters or Get Agent Pools to verify the operation. The provisioning state should update to Canceled within a few seconds of the abort request being accepted. Operation status of last running operation ID on the managed cluster/agent pool, which can be retrieved by performing a GET operation against the Managed Cluster or agent pool, should show a status of Canceling.

Next steps

Learn more about Container insights to understand how it helps you monitor the performance and health of your Kubernetes cluster and container workloads.