Azure Batch 中的文件和目录Files and directories in Azure Batch

在 Azure Batch 中,每个任务都有一个工作目录,任务可以在该目录中创建文件和目录。In Azure Batch, each task has a working directory under which it can create files and directories. 此工作目录可用于存储任务运行的程序、任务处理的数据,以及任务执行的处理的输出。This working directory can be used for storing the program that is run by the task, the data that it processes, and the output of the processing it performs. 任务的所有文件和目录由任务用户拥有。All files and directories of a task are owned by the task user.

Batch 服务在节点上公开文件系统的一部分作为 根目录The Batch service exposes a portion of the file system on a node as the root directory. 此根目录位于 VM 的临时存储驱动器上,而不是直接位于 OS 驱动器上。This root directory is located on the temporary storage drive of the VM, not directly on the OS drive.

任务可通过引用 AZ_BATCH_NODE_ROOT_DIR 环境变量来访问根目录。Tasks can access the root directory by referencing the AZ_BATCH_NODE_ROOT_DIR environment variable. 有关使用环境变量的详细信息,请参阅 任务的环境设置For more information about using environment variables, see Environment settings for tasks.

根目录结构Root directory structure

根目录包含以下目录结构:The root directory contains the following directory structure:

计算节点目录结构的屏幕截图。

  • applications:包含计算节点上安装的应用程序包的详细信息。applications: Contains information about the details of application packages installed on the compute node. 任务可通过引用 AZ_BATCH_APP_PACKAGE 环境变量来访问此目录。Tasks can access this directory by referencing the AZ_BATCH_APP_PACKAGE environment variable.

  • fsmounts:该目录包含计算节点上装载的所有文件系统。fsmounts: The directory contains any file systems that are mounted on a compute node. 任务可通过引用 AZ_BATCH_NODE_MOUNTS_DIR 环境变量来访问此目录。Tasks can access this directory by referencing the AZ_BATCH_NODE_MOUNTS_DIR environment variable. 有关详细信息,请参阅 在 Batch 池上装载虚拟文件系统For more information, see Mount a virtual file system on a Batch pool.

  • 共享:此目录允许对节点上运行的“所有”任务进行读取/写入访问。shared: This directory provides read/write access to all tasks that run on a node. 在节点上运行的任何任务都可以创建、读取、更新和删除此目录中的文件。Any task that runs on the node can create, read, update, and delete files in this directory. 任务可通过引用 AZ_BATCH_NODE_SHARED_DIR 环境变量来访问此目录。Tasks can access this directory by referencing the AZ_BATCH_NODE_SHARED_DIR environment variable.

  • 启动:启动任务使用此目录作为它的工作目录。startup: This directory is used by a start task as its working directory. 由启动任务下载到的节点所有文件都存储在此处。All of the files that are downloaded to the node by the start task are stored here. 启动任务可以创建、读取、更新和删除此目录下的文件。The start task can create, read, update, and delete files under this directory. 任务可通过引用 AZ_BATCH_NODE_STARTUP_DIR 环境变量来访问此目录。Tasks can access this directory by referencing the AZ_BATCH_NODE_STARTUP_DIR environment variable.

  • volatile:此目录供内部使用。volatile: This directory is for internal purposes. 不保证此目录中的任何文件或此目录本身未来一定存在。There's no guarantee that any files in this directory or that the directory itself will exist in the future.

  • workitems:此目录包含计算节点上作业及其任务的目录。workitems: This directory contains the directories for jobs and their tasks on the compute node.

    在 workitems 目录中,为节点上运行的每个任务创建一个 Tasks 目录 。Within the workitems directory, a Tasks directory is created for each task that runs on the node. 此目录可通过引用 AZ_BATCH_TASK_DIR 环境变量进行访问。This directory can be accessed by referencing the AZ_BATCH_TASK_DIR environment variable.

    在每个 Tasks 目录中,Batch 服务会创建一个工作目录 (wd),该目录的唯一路径由 AZ_BATCH_TASK_WORKING_DIR 环境变量进行指定。Within each Tasks directory, the Batch service creates a working directory (wd) whose unique path is specified by the AZ_BATCH_TASK_WORKING_DIR environment variable. 此目录提供对任务的读/写访问权限。This directory provides read/write access to the task. 任务可以创建、读取、更新和删除此目录下的文件。The task can create, read, update, and delete files under this directory. 此目录根据指定给任务的 RetentionTime 约束来保留。This directory is retained based on the RetentionTime constraint that is specified for the task.

    在任务执行期间,stdout.txtstderr.txt 文件会写入 Tasks 文件夹。The stdout.txt and stderr.txt files are written to the Tasks folder during the execution of the task.

重要

从池中删除节点时,将一并删除节点上存储的所有文件。When a node is removed from the pool, all of the files that are stored on the node are removed.

后续步骤Next steps