I'm new to Azure Cli, I have been trying a basic task, but I dont know why it never finish, any idea?
then I executed this in Azure Cli/Powershell
az account set --subscription "Some Azure Subscription"
az batch account login --name "somename" --resource-group "myresourcegroup" --shared-key-auth
az batch task create --job-id test-job-1 --task-id task1 --command-line "echo 'test'"
the task never ends, when I see the info:
any ideas?
Azure CLI Never Ending task
The task is stuck in an active state with n/a
for both pool and node.
Ensure the pool is in the Steady state, indicating it is available for tasks to be assigned. In the Pool Overview page, check the Nodes heatmap. Ensure that the nodes are in the Idle state. If the nodes are in Unusable, Creating, or Starting states, the task cannot be assigned to those nodes.
Scale the pool by adding more dedicated nodes and ensure nodes are idle. If issue is still present means, restart or delete the node, re-create the job
If the task still did not assign to the node after scaling and node checks, delete the present job and task that had stuck.
Create a new job and assign it to the properly configured pool with available nodes.
az batch task create --job-id <Your JobName> --task-id <Your taskName> --command-line "powershell -NoProfile -Command \"echo test\"" --account-name <Your BatchAccountName>
Check the job and task are assigned and configured correctly
az batch task show --job-id <Your JobName> --task-id <Your taskName> --account-name <Your Batchaccount Name>
Output:
PS C:\Windows\system32> az batch task create --job-id my-new-job --task-id echo4 --command-line "powershell -NoProfile -Command \"echo test\"" --account-name "batchaccount234"
{
"commandLine": "powershell -NoProfile -Command \"echo test\" --account-name batchaccount234",
"constraints": {
"maxTasksRetryCount": 0,
"maxWallClockTime": "P10675199DT248H55M4775807S",
"retentionTime": "P7D"
},
"creationTime": "2025-06-11T06:10:16.548949Z",
"eTag": "\"x8DBDA8AEA2D726\"",
"executionInfo": {
"requestCount": 0,
"retryCount": 0
},
"id": "echo4",
"lastModified": "2025-06-11T06:10:16.548949Z",
"odata.metadata": "https://batchaccount234.eastus.batch.azure.com/$metadata#tasks/@Element",
"state": "active",
"stateTransitionTime": "2025-06-11T06:10:16.548949Z",
"url": "https://batchaccount234.eastus.batch.azure.com/jobs/my-new-job/tasks/echo4",
"userIdentity": {
"autoUser": {
"elevationLevel": "nonadmin",
"scope": "pool"
}
}
}
Configured successfully
{
"commandLine": "powershell -NoProfile -Command \"echo test\\ --account-name batchaccount234\"",
"constraints": {
"maxTaskRetryCount": 0,
"maxWallClockTime": "P10675199DT2H48M5.4775807S",
"retentionTime": "P7D"
},
"creationTime": "2025-06-11T06:10:16.5849894Z",
"eTag": "0x8DDA8AEA2D0D726",
"executionInfo": {
"endTime": "2025-06-11T06:10:26.237115Z",
"exitCode": 0,
"requeueCount": 0,
"result": "success",
"retryCount": 0,
"startTime": "2025-06-11T06:10:25.643379Z"
},
"id": "echo4",
"lastModified": "2025-06-11T06:10:16.5849894Z",
"nodeInfo": {
"affinityId": "TVM:tvmps_31748d692bc604538ae301b8bb9b620d46eb64ae6fb1981713ae8a3d4d267af1_d",
"nodeId": "tvmps_31748d692bc604538ae301b8bb9b620d46eb64ae6fb1981713ae8a3d4d267af1_d",
"nodeUrl": "https://batchaccount234.eastus.batch.azure.com/pools/mypool/nodes/tvmps_31748d692bc604538ae301b8bb9b620d46eb64ae6fb1981713ae8a3d4d267af1_d",
"poolId": "mypool",
"taskRootDirectory": "workitems\\my-new-job\\job-1\\echo4",
"taskRootDirectoryUrl": "https://batchaccount234.eastus.batch.azure.com/pools/mypool/nodes/tvmps_31748d692bc604538ae301b8bb9b620d46eb64ae6fb1981713ae8a3d4d267af1_d/files/workitems/my-new-job/job-1/echo4"
},
"odata.metadata": "https://batchaccount234.eastus.batch.azure.com/$metadata#tasks/@Element",
"previousState": "running",
"previousStateTransitionTime": "2025-06-11T06:10:25.580869Z",
"requiredSlots": 1,
"state": "completed",
"stateTransitionTime": "2025-06-11T06:10:26.237115Z",
"url": "https://batchaccount234.eastus.batch.azure.com/jobs/my-new-job/tasks/echo4",
"userIdentity": {
"autoUser": {
"elevationLevel": "nonadmin",
"scope": "pool"
}
}
}