1

我是 docker 和 azure batch 的新手。我目前遇到的问题是我有 2 个 dotnet 控制台应用程序,其中一个在本地运行(它以编程方式在 azure 批处理上创建池、作业和任务),第二个我创建了一个 docker 映像并推送到 azure 容器注册表。现在的事情是当我从本地运行的应用程序创建 cloudtTask 作为下面的 monetione

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("-----------------------");

并将其添加到 BatchClient,我在 azure batch(Azure 门户)中得到的期望是这样的:

System.UnauthorizedAccessException:对路径“/home/_azbatch/.dotnet”的访问被拒绝。---> System.IO.IOException: Permission denied --- End of internal exception stack trace ---

可能是什么问题?谢谢你。

4

2 回答 2

2

由于评论最终成为了答案,因此我将其发布在这里是为了让未来的观众更清楚:
该任务需要以提升的权限运行。例如。

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

有关更多信息,请参阅文档

于 2018-07-21T20:33:15.733 回答
0

我仍然无法从 docker 中提取图像,我正在使用 nodejs .. 以下是用于创建任务的配置

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"
      }
    }
  }
于 2021-09-28T12:10:48.313 回答