An Azure service that provides cloud-scale job scheduling and compute management.
Use the following steps to unblock and complete deletion of the stuck Batch pool.
- Confirm the pool is in
deleting/resizing state- Use Azure Portal or CLI to verify the pool state and that it has been stuck for a long time. Batch sets
poolStatetodeletingand resizes nodes to zero before removing the pool object. - If deletion is taking longer than expected, Batch keeps retrying, but certain issues require manual fixes.
- Use Azure Portal or CLI to verify the pool state and that it has been stuck for a long time. Batch sets
- Check for resource locks on the Batch account and its resource group
- In the Azure portal, go to the resource group that contains the Batch account.
- Check Locks on the resource group.
- If there is a lock (for example,
DeleteorReadOnly), remove it. - This resolves Cause 1a where the Batch account’s resource group is locked and prevents delete operations.
- If there is a lock (for example,
- Check Locks on the resource group.
- Then open the Batch account resource.
- Check Locks on the Batch account itself.
- If present, remove the lock.
- This resolves Cause 1b where the Batch account is locked.
- Check Locks on the Batch account itself.
- After removing locks, wait ~20 minutes and re-check the pool; if still present, retry deletion.
- In the Azure portal, go to the resource group that contains the Batch account.
- If the pool uses a virtual network, check locks and dependencies on Batch-created network resources
- When a pool is created in a virtual network, Batch automatically creates:
- Network Security Group (NSG)
- Public IP address
- Load balancer
- Deleting or resizing the pool to zero requires Batch to delete these resources.
- Go to the resource group that contains the virtual network used by the pool.
- Check Locks on that resource group.
- If there is a lock, remove it.
- This resolves Cause 2a where extra networking resources in the resource group are locked and block deletion of the Batch-created load balancer.
- After removing locks, wait ~20 minutes for Batch to complete deletion.
- In the same resource group, locate the Batch-created NSG, public IP, and load balancer (names typically include
azurebatch-cloudserviceloadbalancerorazurebatch-cloudservicenetworksecuritygroup). - If the NSG is associated with other subnets or NICs outside the Batch pool, or if other resources depend on the Batch-created IP or load balancer, Batch cannot delete them and the pool deletion will hang.
- For example, an activity log entry like:
-
Network security group ... cannot be deleted because it is in use by ... virtualNetworks/<vnet>/subnets/<subnet> - indicates Cause 2b.
-
- For example, an activity log entry like:
- Fix by disassociating these dependencies:
- Disassociate the NSG from any subnet or NIC that is not part of the Batch pool (see associate or dissociate a network security group to or from a subnet or network interface).
- After removing dependencies, wait ~20 minutes; Batch should finish deleting the pool and its network resources.
- When a pool is created in a virtual network, Batch automatically creates:
- Retry or monitor deletion via CLI/SDK
- If needed, explicitly request deletion again:
- Azure CLI:
az batch pool delete --pool-id <pool-id> - Or via Python SDK
PoolOperations.delete(pool_id=...).
- Azure CLI:
- Note: If the pool is already in
deletingstate, any further Update/Patch/Delete calls will fail with HTTP 409PoolBeingDeleteduntil the underlying issues (locks/dependencies) are resolved.
- If needed, explicitly request deletion again:
- If deletion still does not complete
- After removing all locks and external dependencies and waiting sufficient time, if the pool remains stuck, check for broader conditions mentioned for pool deletion failures:
- Ensure
Microsoft.Batchresource provider is still registered in the subscription. - For user subscription mode accounts, ensure
Microsoft Azure Batchstill has Contributor or Owner role on the subscription that contains the pool.
- Ensure
- After removing all locks and external dependencies and waiting sufficient time, if the pool remains stuck, check for broader conditions mentioned for pool deletion failures:
Once all locks and external dependencies are cleared and Batch has required permissions, the stuck pool should automatically complete deletion within about 20 minutes; if not, re-issuing the delete request after fixes should succeed.
References: