which says that there are not enough permissions to perform this action
When you use az batch account login -g $resourceGroup -n $batchAccountName
login, it uses Auzre AD authentication, it uses the credential of the account which you logged in with az login
.
If you use the command with --shared-key-auth
parameter, it uses the Shared Key authentication, but your account also needs the permission to do Microsoft.Batch/batchAccounts/listKeys/action
action. At first I thought Reader
role is enough, but per my test, it does not have the permission to list keys of batch account.
So to fix the issue, you could let the Owner
of the subscription/batch account
give your user account which logged in with az login
as an Owner
or Contributor
role. Navigate to the subscription/batch account in the portal -> Access control (IAM)
-> Add
-> Add role assignment
-> search for your user account(or service principal), add it as Owner
/Contributor
role, details here. Then use az account clear
to clear the local cache and run az batch account login -g $resourceGroup -n $batchAccountName
again, az batch task create
will work fine.
How to specify the task's user identity “Pool default user (Admin)” in the azure batch account?
The way is to use --json-file
parameter, based on your requirement, specify the elevationLevel
with nonadmin
or admin
in the .json
file like below.
batch.json
file:
{
"id": "task1",
"commandLine": "bash -c 'echo hello'",
"userIdentity": {
"autoUser": {
"scope": "task",
"elevationLevel": "admin"
}
}
}
Sample:
az batch task create --job-id myjob --json-file C:\Users\joyw\Desktop\batch.json
