1
votes

I am new to docker as well as azure batch. The problem i am having currently is i have 2 dotnet console applications one of them runs locally (which creates the pool, job and task on azure batch programmatically) and for second one i have created a docker image and pushed to azure container registry. Now the things is when i create the cloudtTask from locally running application as monetione below

TaskContainerSettings cmdContainerSettings = new TaskContainerSettings(
            imageName: "myrepository.azurecr.io/pipeline:latest",
            containerRunOptions: "--rm"
        );

        CloudTask containerTask = new CloudTask(
            id: "task1",
            commandline: cmdLine);
        containerTask.ContainerSettings = cmdContainerSettings;

        Console.WriteLine("Task created");
        await batchClient.JobOperations.AddTaskAsync(newJobId, containerTask);
        Console.WriteLine("-----------------------");

and add it to the BatchClient, the expcetion i get in azure batch (Azure portal) is this:

System.UnauthorizedAccessException: Access to the path '/home/_azbatch/.dotnet' is denied. ---> System.IO.IOException: Permission denied --- End of inner exception stack trace ---

What can be the problem? Thank you.

2
Did you try running the task with an elevated user?gezzahead
Thank you @gezzahead i tried with the elevated rights and it worked.Usman Iftakhar

2 Answers

2
votes

As the comment ended up being the answer, I'm posting it here for clarity for future viewers:
The task needs to be run with elevated rights. eg.

containerTask.UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin, scope: AutoUserScope.Task));

See the docs for more info

0
votes

i am still not able to pull image from docker, i am using nodejs .. following are configs for creating task

const taskConfig = {
    "id": "task-new-2",
    "commandLine": "bash -c 'node index.js'",
    "containerSettings": {
      "imageName": "xxx.xx.io/xx-test:latest",
      "containerRunOptions": "--rm",
      "username": "xxx",
      "password": "tfDlZ",
      "registryServer": "xxx.xx.io",
      // "workingDirectory": "AZ_BATCH_NODE_ROOT_DIR"
    },
    "userIdentity": {
      "autoUser": {
        "scope": "pool",
        "elevationLevel": "admin"
      }
    }
  }