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-aad-auth.md
+20-39Lines changed: 20 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@
2
2
title: Authenticate Azure Batch services with Azure Active Directory
3
3
description: Batch supports Azure AD for authentication from the Batch service. Learn how to authenticate in one of two ways.
4
4
ms.topic: how-to
5
-
ms.date: 01/28/2020
5
+
ms.date: 10/20/2020
6
6
ms.custom: has-adal-ref
7
7
---
8
8
9
9
# Authenticate Batch service solutions with Active Directory
10
10
11
-
Azure Batch supports authentication with [Azure Active Directory][aad_about] (Azure AD). Azure AD is Microsoft’s multi-tenant cloud based directory and identity management service. Azure itself uses Azure AD to authenticate its customers, service administrators, and organizational users.
11
+
Azure Batch supports authentication with [Azure Active Directory](../active-directory/fundamentals/active-directory-whatis.md) (Azure AD). Azure AD is Microsoft's multi-tenant cloud based directory and identity management service. Azure itself uses Azure AD to authenticate its customers, service administrators, and organizational users.
12
12
13
13
When using Azure AD authentication with Azure Batch, you can authenticate in one of two ways:
14
14
@@ -35,10 +35,8 @@ To authenticate with Azure AD, you use this endpoint together with the tenant ID
35
35
> The tenant-specific endpoint is required when you authenticate using a service principal.
36
36
>
37
37
> The tenant-specific endpoint is optional when you authenticate using integrated authentication, but recommended. However, you can also use the Azure AD common endpoint. The common endpoint provides a generic credential gathering interface when a specific tenant is not provided. The common endpoint is `https://login.microsoftonline.com/common`.
38
-
>
39
-
>
40
38
41
-
For more information about Azure AD endpoints, see [Authentication Scenarios for Azure AD][aad_auth_scenarios].
39
+
For more information about Azure AD endpoints, see [Authentication vs. authorization]()../active-directory/develop/authentication-vs-authorization.md).
42
40
43
41
### Batch resource endpoint
44
42
@@ -48,17 +46,15 @@ Use the **Azure Batch resource endpoint** to acquire a token for authenticating
48
46
49
47
## Register your application with a tenant
50
48
51
-
The first step in using Azure AD to authenticate is registering your application in an Azure AD tenant. Registering your application enables you to call the Azure [Active Directory Authentication Library][aad_adal] (ADAL) from your code. The ADAL provides an API for authenticating with Azure AD from your application. Registering your application is required whether you plan to use integrated authentication or a service principal.
49
+
The first step in using Azure AD to authenticate is registering your application in an Azure AD tenant. Registering your application enables you to call the Azure [Active Directory Authentication Library](../active-directory/azuread-dev/active-directory-authentication-libraries.md) (ADAL) from your code. The ADAL provides an API for authenticating with Azure AD from your application. Registering your application is required whether you plan to use integrated authentication or a service principal.
52
50
53
51
When you register your application, you supply information about your application to Azure AD. Azure AD then provides an application ID (also called a *client ID*) that you use to associate your application with Azure AD at runtime. To learn more about the application ID, see [Application and service principal objects in Azure Active Directory](../active-directory/develop/app-objects-and-service-principals.md).
54
52
55
-
To register your Batch application, follow the steps in the [Adding an Application](../active-directory/develop/quickstart-register-app.md) section in [Integrating applications with Azure Active Directory][aad_integrate]. If you register your application as a Native Application, you can specify any valid URI for the **Redirect URI**. It does not need to be a real endpoint.
53
+
To register your Batch application, follow the steps in the **Register an application** section in [Quickstart: Register an application with the Microsoft identity platform](../active-directory/develop/quickstart-register-app.md). If you register your application as a Native Application, you can specify any valid URI for the **Redirect URI**. It does not need to be a real endpoint.
56
54
57
55
After you've registered your application, you'll see the application ID:
58
56
59
-

60
-
61
-
For more information about registering an application with Azure AD, see [Authentication Scenarios for Azure AD](../active-directory/develop/authentication-vs-authorization.md).
57
+

62
58
63
59
## Get the tenant ID for your Active Directory
64
60
@@ -68,31 +64,26 @@ The tenant ID identifies the Azure AD tenant that provides authentication servic
68
64
1. Select **Properties**.
69
65
1. Copy the GUID value provided for the **Directory ID**. This value is also called the tenant ID.
70
66
71
-

67
+

72
68
73
69
## Use integrated authentication
74
70
75
71
To authenticate with integrated authentication, you need to grant your application permissions to connect to the Batch service API. This step enables your application to authenticate calls to the Batch service API with Azure AD.
76
72
77
73
Once you've registered your application, follow these steps in the Azure portal to grant it access to the Batch service:
78
74
79
-
1. In the left-hand navigation pane of the Azure portal, choose **All services**. Select **App Registrations**.
80
-
1. Search for the name of your application in the list of app registrations:
81
-
82
-

83
-
75
+
1. In the Azure portal, choose **All services**, then select **App Registrations**.
76
+
1. Search for the name of your application in the list of app registrations.
84
77
1. Select the application and select **API permissions**.
85
78
1. In the **API permissions** section, select **Add a permission**.
86
79
1. In **Select an API**, search for the Batch API. Search for each of these strings until you find the API:
87
80
1.**Microsoft Azure Batch**
88
81
1.**ddbf3205-c6bd-46ae-8127-60eb93363864** is the ID for the Batch API.
89
-
1. Once you find the Batch API, select it and select**Select**.
82
+
1. Once you find the Batch API, select it and then choose**Select**.
90
83
1. In **Select permissions**, select the check box next to **Access Azure Batch Service** and then select **Add permissions**.
91
84
92
85
The **API permissions** section now shows that your Azure AD application has access to both Microsoft Graph and the Batch service API. Permissions are granted to Microsoft Graph automatically when you first register your app with Azure AD.
93
86
94
-

95
-
96
87
## Use a service principal
97
88
98
89
To authenticate an application that runs unattended, you use a service principal. After you've registered your application, follow these steps in the Azure portal to configure a service principal:
@@ -106,14 +97,12 @@ When your application authenticates with a service principal, it sends both the
106
97
107
98
Follow these steps in the Azure portal:
108
99
109
-
1. In the left-hand navigation pane of the Azure portal, choose **All services**. Select **App Registrations**.
100
+
1. In the Azure portal, choose **All services**. Select **App Registrations**.
110
101
1. Select your application from the list of app registrations.
111
102
1. Select the application and then select **Certificates & secrets**. In the **Client secrets** section, select **New client secret**.
112
-
1. To create a secret, enter a description for the secret. Then select an expirations for the secret of either one year, two years, or no expiration..
103
+
1. To create a secret, enter a description for the secret. Then select an expiration for the secret of either one year, two years, or no expiration.
113
104
1. Select **Add** to create and display the secret. Copy the secret value to a safe place, as you won't be able to access it again after you leave the page.
114
105
115
-

116
-
117
106
### Assign Azure RBAC to your application
118
107
119
108
To authenticate with a service principal, you need to assign Azure RBAC to your application. Follow these steps:
@@ -152,6 +141,9 @@ You can use a custom role to grant permissions to an Azure AD user, group, or se
152
141
153
142
Custom roles are for users authenticated by Azure AD, not the Batch account credentials (shared key). Note that the Batch account credentials give full permission to the Batch account. Also note that jobs using autopool require pool-level permissions.
154
143
144
+
> [!NOTE]
145
+
> Certain role assignments need to be specified in the Action field, whereas others need to be specified in the DataAction field. For more information, see [Azure resource provider operations](../role-based-access-control/resource-provider-operations.md#microsoftbatch).
146
+
155
147
Here's an example of a custom role definition:
156
148
157
149
```json
@@ -188,7 +180,7 @@ Here's an example of a custom role definition:
188
180
}
189
181
```
190
182
191
-
For more general information on creating a custom role, see [Azure custom roles](../role-based-access-control/custom-roles.md).
183
+
For more information on creating a custom role, see [Azure custom roles](../role-based-access-control/custom-roles.md).
192
184
193
185
### Get the tenant ID for your Azure Active Directory
194
186
@@ -207,10 +199,7 @@ The code examples in this section show how to authenticate with Azure AD using i
207
199
> [!NOTE]
208
200
> An Azure AD authentication token expires after one hour. When using a long-lived **BatchClient** object, we recommend that you retrieve a token from ADAL on every request to ensure you always have a valid token.
209
201
>
210
-
>
211
-
> To achieve this in .NET, write a method that retrieves the token from Azure AD and pass that method to a **BatchTokenCredentials** object as a delegate. The delegate method is called on every request to the Batch service to ensure that a valid token is provided. By default ADAL caches tokens, so a new token is retrieved from Azure AD only when necessary. For more information about tokens in Azure AD, see [Authentication Scenarios for Azure AD][aad_auth_scenarios].
212
-
>
213
-
>
202
+
> To achieve this in .NET, write a method that retrieves the token from Azure AD and pass that method to a **BatchTokenCredentials** object as a delegate. The delegate method is called on every request to the Batch service to ensure that a valid token is provided. By default ADAL caches tokens, so a new token is retrieved from Azure AD only when necessary. For more information about tokens in Azure AD, see [Security tokens](../active-directory/develop/security-tokens.md).
214
203
215
204
### Code example: Using Azure AD integrated authentication with Batch .NET
216
205
@@ -414,16 +403,8 @@ Use the service principal credentials to open a **BatchServiceClient** object. T
414
403
415
404
## Next steps
416
405
417
-
- To learn more about Azure AD, see the [Azure Active Directory Documentation](../active-directory/index.yml). In-depth examples showing how to use ADAL are available in the [Azure Code Samples](https://azure.microsoft.com/resources/samples/?service=active-directory) library.
418
-
419
-
- To learn more about service principals, see [Application and service principal objects in Azure Active Directory](../active-directory/develop/app-objects-and-service-principals.md). To create a service principal using the Azure portal, see [Use portal to create Active Directory application and service principal that can access resources](../active-directory/develop/howto-create-service-principal-portal.md). You can also create a service principal with PowerShell or Azure CLI.
420
-
421
-
- To authenticate Batch Management applications using Azure AD, see [Authenticate Batch Management solutions with Active Directory](batch-aad-auth-management.md).
422
-
406
+
- Review the [Azure Active Directory Documentation](../active-directory/index.yml). In-depth examples showing how to use ADAL are available in the [Azure Code Samples](https://azure.microsoft.com/resources/samples/?service=active-directory) library.
407
+
- Learn about [Application and service principal objects in Azure Active Directory](../active-directory/develop/app-objects-and-service-principals.md) and [how to create an Azure AD application and service principal that can access resources](../active-directory/develop/howto-create-service-principal-portal.md).
408
+
- Learn about [authenticating Batch Management solutions with Active Directory](batch-aad-auth-management.md).
423
409
- For a Python example of how to create a Batch client authenticated using an Azure AD token, see the [Deploying Azure Batch Custom Image with a Python Script](https://github.com/azurebigcompute/recipes/blob/master/Azure%20Batch/CustomImages/CustomImagePython.md) sample.
424
410
425
-
[aad_about]: ../active-directory/fundamentals/active-directory-whatis.md"What is Azure Active Directory?"
0 commit comments