Currently I do the following to see if a job exists:
id=$(az batch job show \
--job-id $1 \
--query id \
--output tsv \
--account-key $AZ_BATCH_KEY \
--account-name $AZ_BATCH_ACCOUNT \
--account-endpoint $AZ_BATCH_ENDPOINT)
if [ "$id" == "" ]; then
# create job
else
# enable job
fi
Is there a more robust way to do this?
Basically, I want to check if a job already exists. If it does, I want to enable it and add tasks to it. Otherwise, I will create it and add tasks.
I am using the auto pool feature to create a pool on job creation and delete the pool on job termination.