I have need to reboot all Nodes in Azure Batch. How can i do that using Azure CLI ?
Essentially how can i iterate over List/Collection in Azure CLI and call command within that loop to stop the VM
I have need to reboot all Nodes in Azure Batch. How can i do that using Azure CLI ?
Essentially how can i iterate over List/Collection in Azure CLI and call command within that loop to stop the VM
There is no one command can do this, but you could use a script to reboot all nodes. If you use bash shell, you could use the following example:
pools="$(az batch pool list |grep id|awk -F\" '{print $4}')"
for pool in $pools
{
nodes="$(az batch node list --pool-id $name|grep -F "id\":"|awk -F\" '{print $4}')"
for node in $nodes
{
az batch node reboot --node-id $node --pool-id $pool
}
}
If you could use Power Shell, you could reboot all nodes by using
Get-AzureBatchComputeNode -PoolId "MyPool" -BatchContext $Context | Restart-AzureBatchComputeNode -BatchContext $Context
More information about this see this link.