You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/batch/batch-user-accounts.md
+27-23Lines changed: 27 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Run tasks under user accounts
3
3
description: Learn the types of user accounts and how to configure them.
4
4
ms.topic: how-to
5
-
ms.date: 08/27/2024
5
+
ms.date: 02/28/2025
6
6
ms.custom:
7
7
ms.devlang: csharp
8
8
# ms.devlang: csharp, java, python
@@ -13,16 +13,14 @@ ms.devlang: csharp
13
13
> The user accounts discussed in this article are different from user accounts used for Remote Desktop Protocol (RDP) or Secure Shell (SSH), for security reasons.
14
14
>
15
15
> To connect to a node running the Linux virtual machine configuration via SSH, see [Install and configure xrdp to use Remote Desktop with Ubuntu](/azure/virtual-machines/linux/use-remote-desktop). To connect to nodes running Windows via RDP, see [How to connect and sign on to an Azure virtual machine running Windows](/azure/virtual-machines/windows/connect-logon).
16
-
>
17
-
> To connect to a node running the via RDP, see [Enable Remote Desktop Connection for a Role in Azure Cloud Services](../cloud-services/cloud-services-role-enable-remote-desktop-new-portal.md).
18
16
19
17
A task in Azure Batch always runs under a user account. By default, tasks run under standard user accounts, without administrator permissions. For certain scenarios, you may want to configure the user account under which you want a task to run. This article discusses the types of user accounts and how to configure them for your scenario.
20
18
21
19
## Types of user accounts
22
20
23
21
Azure Batch provides two types of user accounts for running tasks:
24
22
25
-
-**Auto-user accounts.** Auto-user accounts are built-in user accounts that are created automatically by the Batch service. By default, tasks run under an auto-user account. You can configure the auto-user specification for a task to indicate under which auto-user account a task should run. The auto-user specification allows you to specify the elevation level and scope of the auto-user account that will run the task.
23
+
-**Auto-user accounts.** Auto-user accounts are built-in user accounts that are created automatically by the Batch service. By default, tasks run under an auto-user account. You can configure the auto-user specification for a task to indicate under which auto-user account a task should run. The auto-user specification allows you to specify the elevation level and scope of the auto-user account that runs the task.
26
24
27
25
-**A named user account.** You can specify one or more named user accounts for a pool when you create the pool. Each user account is created on each node of the pool. In addition to the account name, you specify the user account password, elevation level, and, for Linux pools, the SSH private key. When you add a task, you can specify the named user account under which that task should run.
28
26
@@ -35,6 +33,12 @@ Both an auto-user account and a named user account have read/write access to the
35
33
36
34
If a task runs under the same account that was used for running a start task, the task has read-write access to the start task directory. Similarly, if a task runs under the same account that was used for running a job preparation task, the task has read-write access to the job preparation task directory. If a task runs under a different account than the start task or job preparation task, then the task has only read access to the respective directory.
37
35
36
+
> [!IMPORTANT]
37
+
> Distinct task users in Batch aren't a sufficient security boundary for isolation between tasks and its associated task data.
38
+
> In Batch, the security isolation boundary is at the pool level. However improper access control of the Batch
39
+
> API can lead to access of all pools under a Batch account with sufficient permission. Refer to best practices about
For more information on accessing files and directories from a task, see [Files and directories](files-and-directories.md).
39
43
40
44
## Elevated access for tasks
@@ -57,15 +61,18 @@ There are four possible configurations for the auto-user specification, each of
57
61
- Non-admin access with pool scope
58
62
- Admin access with pool scope
59
63
60
-
> [!IMPORTANT]
61
-
> Tasks running under task scope do not have de facto access to other tasks on a node. However, a malicious user with access to the account could work around this restriction by submitting a task that runs with administrator privileges and accesses other task directories. A malicious user could also use RDP or SSH to connect to a node. It's important to protect access to your Batch account keys to prevent such a scenario. If you suspect your account may have been compromised, be sure to regenerate your keys.
64
+
> [!NOTE]
65
+
> Auto-user accounts with elevated admin access have direct write access to all other task directories on the compute node executing
66
+
> the task. Consider running your tasks with the least privilege required for successful execution.
62
67
63
68
### Run a task as an auto-user with elevated access
64
69
65
70
You can configure the auto-user specification for administrator privileges when you need to run a task with elevated access. For example, a start task may need elevated access to install software on the node.
66
71
67
72
> [!NOTE]
68
-
> Use elevated access only when necessary. Best practices recommend granting the minimum privilege necessary to achieve the desired outcome. For example, if a start task installs software for the current user, instead of for all users, you may be able to avoid granting elevated access to tasks. You can configure the auto-user specification for pool scope and non-admin access for all tasks that need to run under the same account, including the start task.
73
+
> Use elevated access only when necessary. A typical use case for using elevated admin access is for a start task that must install
74
+
> software on the compute node before other tasks can be scheduled. For subsequent tasks, you should use the installed software
75
+
> as a task user without elevation.
69
76
70
77
The following code snippets show how to configure the auto-user specification. The examples set the elevation level to `Admin` and the scope to `Task`.
71
78
@@ -106,14 +113,12 @@ When a node is provisioned, two pool-wide auto-user accounts are created on each
106
113
107
114
When you specify pool scope for the auto-user, all tasks that run with administrator access run under the same pool-wide auto-user account. Similarly, tasks that run without administrator permissions also run under a single pool-wide auto-user account.
108
115
109
-
> [!NOTE]
110
-
> The two pool-wide auto-user accounts are separate accounts. Tasks running under the pool-wide administrative account can't share data with tasks running under the standard account, and vice versa.
111
-
112
-
The advantage to running under the same auto-user account is that tasks are able to share data with other tasks running on the same node.
116
+
The advantage to running under the same auto-user account is that tasks are able to easily share data with other tasks running
117
+
on the same node. There are also performance benefits to user account reuse.
113
118
114
119
Sharing secrets between tasks is one scenario where running tasks under one of the two pool-wide auto-user accounts is useful. For example, suppose a start task needs to provision a secret onto the node that other tasks can use. You could use the Windows Data Protection API (DPAPI), but it requires administrator privileges. Instead, you can protect the secret at the user level. Tasks running under the same user account can access the secret without elevated access.
115
120
116
-
Another scenario where you may want to run tasks under an auto-user account with pool scope is a Message Passing Interface (MPI) file share. An MPI file share is useful when the nodes in the MPI task need to work on the same file data. The head node creates a file share that the child nodes can access if they are running under the same auto-user account.
121
+
Another scenario where you may want to run tasks under an auto-user account with pool scope is a Message Passing Interface (MPI) file share. An MPI file share is useful when the nodes in the MPI task need to work on the same file data. The head node creates a file share that the child nodes can access if they're running under the same auto-user account.
117
122
118
123
The following code snippet sets the auto-user's scope to pool scope for a task in Batch .NET. The elevation level is omitted, so the task runs under the standard pool-wide auto-user account.
119
124
@@ -146,13 +151,13 @@ Console.WriteLine("Creating pool [{0}]...", poolId);
146
151
// Create a pool using Virtual Machine Configuration.
Copy file name to clipboardExpand all lines: articles/batch/best-practices.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Best practices
3
3
description: Learn best practices and useful tips for developing your Azure Batch solutions.
4
-
ms.date: 06/27/2024
4
+
ms.date: 02/28/2025
5
5
ms.topic: conceptual
6
6
---
7
7
@@ -65,6 +65,10 @@ supported indefinitely. An EOL date may be added or updated in the future at any
65
65
66
66
For the purposes of isolation, if your scenario requires isolating jobs or tasks from each other, do so by having them in separate pools. A pool is the security isolation boundary in Batch, and by default, two pools aren't visible or able to communicate with each other. Avoid using separate Batch accounts as a means of security isolation unless the larger environment from which the Batch account operates in requires isolation.
67
67
68
+
If desired, proper access control must be applied on the Batch account and APIs to prevent access to all pools under the Batch account.
69
+
It's recommended to disable shared key access and only allow Entra-based authentication to enable
Batch node agents aren't automatically upgraded for pools that have nonzero compute nodes. To ensure your Batch pools receive the latest security fixes and updates to the Batch node agent, you need to either resize the pool to zero compute nodes or recreate the pool. It's recommended to monitor the [Batch Node Agent release notes](https://github.com/Azure/Batch/blob/master/changelogs/nodeagent/CHANGELOG.md) to understand changes to new Batch node agent versions. Checking regularly for updates when they were released enables you to plan upgrades to the latest agent version.
0 commit comments