1. Create a resource group : An Azure resource group is a logical container into which Azure resources are deployed and managed.
az group create \
--name myResourceGroup \
--location eastus2
2.Create a Storage Account: the storage account is useful to deploy applications and store input and output data for most real-world workloads
az storage account create \
--resource-group myResourceGroup \
--name mystorageaccount \
--location eastus2 \
--sku Standard_LRS
3. Create a Batch Account : an account is needed to create compute resources (pools of compute nodes) and Batch jobs.
az batch account create \
--name mybatchaccount \
--storage-account mystorageaccount \
--resource-group myResourceGroup \
--location eastus2
To create and manage compute pools and jobs, you need to authenticate with Batch.
4.Create a pool
az batch pool create \
--id mypool --vm-size Standard_A1_v2 \
--target-dedicated-nodes 2 \
--image canonical:ubuntuserver:16.04-LTS \
--node-agent-sku-id "batch.node.ubuntu 16.04"
Batch creates the pool immediately, but it takes a few minutes to allocate and start the compute nodes. During this time, the pool is in the resizing state. To see the status of the pool, run the az batch pool show command. This command shows all the properties of the pool, and you can query for specific properties. The following command gets the allocation state of the pool:
az batch pool show --pool-id mypool \
--query "allocationState"
The pool is ready to run tasks when the allocation state is steady and all the nodes are running.
5. Create a Job
az batch job create \
--id myjob \
--pool-id mypool
6. Create Task
Now use the az batch task create command to create some tasks to run in the job. In this example, you create four identical tasks. Each task runs a command-line to display the Batch environment variables on a compute node, and then waits 90 seconds. When you use Batch, this command line is where you specify your app or script. Batch provides a number of ways to deploy apps and scripts to compute nodes.
The following Bash script creates 4 parallel tasks (mytask1 to mytask4).
for i in {1..4}
do
az batch task create \
--task-id mytask$i \
--job-id myjob \
--command-line "/bin/bash -c 'printenv | grep AZ_BATCH; sleep 90s'"
done
7.View Task Status
az batch task show \
--job-id myjob \
--task-id mytask1
An
Source: https://docs.microsoft.com/en-us/azure/batch/quick-create-cli
az group create \
--name myResourceGroup \
--location eastus2
2.Create a Storage Account: the storage account is useful to deploy applications and store input and output data for most real-world workloads
az storage account create \
--resource-group myResourceGroup \
--name mystorageaccount \
--location eastus2 \
--sku Standard_LRS
3. Create a Batch Account : an account is needed to create compute resources (pools of compute nodes) and Batch jobs.
az batch account create \
--name mybatchaccount \
--storage-account mystorageaccount \
--resource-group myResourceGroup \
--location eastus2
To create and manage compute pools and jobs, you need to authenticate with Batch.
az batch account login \
--name mybatchaccount \
--resource-group myResourceGroup \
--shared-key-auth
4.Create a pool
az batch pool create \
--id mypool --vm-size Standard_A1_v2 \
--target-dedicated-nodes 2 \
--image canonical:ubuntuserver:16.04-LTS \
--node-agent-sku-id "batch.node.ubuntu 16.04"
Batch creates the pool immediately, but it takes a few minutes to allocate and start the compute nodes. During this time, the pool is in the resizing state. To see the status of the pool, run the az batch pool show command. This command shows all the properties of the pool, and you can query for specific properties. The following command gets the allocation state of the pool:
az batch pool show --pool-id mypool \
--query "allocationState"
The pool is ready to run tasks when the allocation state is steady and all the nodes are running.
5. Create a Job
az batch job create \
--id myjob \
--pool-id mypool
6. Create Task
Now use the az batch task create command to create some tasks to run in the job. In this example, you create four identical tasks. Each task runs a command-line to display the Batch environment variables on a compute node, and then waits 90 seconds. When you use Batch, this command line is where you specify your app or script. Batch provides a number of ways to deploy apps and scripts to compute nodes.
The following Bash script creates 4 parallel tasks (mytask1 to mytask4).
for i in {1..4}
do
az batch task create \
--task-id mytask$i \
--job-id myjob \
--command-line "/bin/bash -c 'printenv | grep AZ_BATCH; sleep 90s'"
done
7.View Task Status
az batch task show \
--job-id myjob \
--task-id mytask1
An
exitCode
of 0 indicates that the task command line completed successfully. The nodeId
indicates the ID of the pool node on which the task ran.Source: https://docs.microsoft.com/en-us/azure/batch/quick-create-cli
No comments:
Post a Comment