Skip to content

Commit 13f801a

Browse files
Merge pull request #166489 from hongli750210/Task#343664
Update DataLake Store SDK from Track1 to Track2
2 parents 3609433 + c4323e8 commit 13f801a

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed
Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Service-to-service authentication - Data Lake Storage Gen1 – Java SDK
3-
description: Learn how to achieve service-to-service authentication with Azure Data Lake Storage Gen1 using Azure Active Directory with Java
2+
title: Service-to-service authentication - Data Lake Storage Gen2 – Java SDK
3+
description: Learn how to achieve service-to-service authentication with Azure Data Lake Storage Gen2 using Azure Active Directory with Java
44

55
author: normesta
66
ms.service: data-lake-store
@@ -10,7 +10,7 @@ ms.custom: devx-track-java
1010
ms.author: normesta
1111

1212
---
13-
# Service-to-service authentication with Azure Data Lake Storage Gen1 using Java
13+
# Service-to-service authentication with Azure Data Lake Storage Gen2 using Java
1414

1515
> [!div class="op_single_selector"]
1616
> * [Using Java](data-lake-store-service-to-service-authenticate-java.md)
@@ -20,13 +20,13 @@ ms.author: normesta
2020
>
2121
>
2222
23-
In this article, you learn about how to use the Java SDK to do service-to-service authentication with Azure Data Lake Storage Gen1. End-user authentication with Data Lake Storage Gen1 using Java SDK is not supported.
23+
In this article, you learn about how to use the Java SDK to do service-to-service authentication with Azure Data Lake Storage Gen2. End-user authentication with Data Lake Storage Gen2 using the Java SDK isn't supported.
2424

2525
## Prerequisites
2626

2727
* **An Azure subscription**. See [Get Azure free trial](https://azure.microsoft.com/pricing/free-trial/).
2828

29-
* **Create an Azure Active Directory "Web" Application**. You must have completed the steps in [Service-to-service authentication with Data Lake Storage Gen1 using Azure Active Directory](data-lake-store-service-to-service-authenticate-using-active-directory.md).
29+
* **Create an Azure Active Directory "Web" Application**. You must have completed the steps in [Service-to-service authentication with Data Lake Storage Gen2 using Azure Active Directory](data-lake-store-service-to-service-authenticate-using-active-directory.md).
3030

3131
* [Maven](https://maven.apache.org/install.html). This tutorial uses Maven for build and project dependencies. Although it is possible to build without using a build system like Maven or Gradle, these systems make it much easier to manage dependencies.
3232

@@ -41,9 +41,14 @@ In this article, you learn about how to use the Java SDK to do service-to-servic
4141
```xml
4242
<dependencies>
4343
<dependency>
44-
<groupId>com.microsoft.azure</groupId>
45-
<artifactId>azure-data-lake-store-sdk</artifactId>
46-
<version>2.2.3</version>
44+
<groupId>com.azure</groupId>
45+
<artifactId>azure-storage-file-datalake</artifactId>
46+
<version>12.6.0</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.azure</groupId>
50+
<artifactId>azure-identity</artifactId>
51+
<version>1.3.3</version>
4752
</dependency>
4853
<dependency>
4954
<groupId>org.slf4j</groupId>
@@ -53,35 +58,39 @@ In this article, you learn about how to use the Java SDK to do service-to-servic
5358
</dependencies>
5459
```
5560

56-
The first dependency is to use the Data Lake Storage Gen1 SDK (`azure-data-lake-store-sdk`) from the maven repository. The second dependency is to specify the logging framework (`slf4j-nop`) to use for this application. The Data Lake Storage Gen1 SDK uses [slf4j](https://www.slf4j.org/) logging façade, which lets you choose from a number of popular logging frameworks, like log4j, Java logging, logback, etc., or no logging. For this example, we disable logging, hence we use the **slf4j-nop** binding. To use other logging options in your app, see [here](https://www.slf4j.org/manual.html#projectDep).
61+
The first dependency is to use the Data Lake Storage Gen2 SDK (`azure-storage-file-datalake`) from the Maven repository. The second dependency is to specify the logging framework (`slf4j-nop`) to use for this app. The Data Lake Storage Gen2 SDK uses the [slf4j](https://www.slf4j.org/) logging façade, which lets you choose from a number of popular logging frameworks, like log4j, Java logging, logback, or no logging. For this example, we disable logging, hence we use the **slf4j-nop** binding. To use other logging options in your app, see [Declaring project dependencies for logging](https://www.slf4j.org/manual.html#projectDep).
5762

5863
3. Add the following import statements to your application.
5964

6065
```java
61-
import com.microsoft.azure.datalake.store.ADLException;
62-
import com.microsoft.azure.datalake.store.ADLStoreClient;
63-
import com.microsoft.azure.datalake.store.DirectoryEntry;
64-
import com.microsoft.azure.datalake.store.IfExists;
65-
import com.microsoft.azure.datalake.store.oauth2.AccessTokenProvider;
66-
import com.microsoft.azure.datalake.store.oauth2.ClientCredsTokenProvider;
66+
import com.azure.identity.ClientSecretCredential;
67+
import com.azure.identity.ClientSecretCredentialBuilder;
68+
import com.azure.storage.file.datalake.DataLakeDirectoryClient;
69+
import com.azure.storage.file.datalake.DataLakeFileClient;
70+
import com.azure.storage.file.datalake.DataLakeServiceClient;
71+
import com.azure.storage.file.datalake.DataLakeServiceClientBuilder;
72+
import com.azure.storage.file.datalake.DataLakeFileSystemClient;
73+
import com.azure.storage.file.datalake.models.ListPathsOptions;
74+
import com.azure.storage.file.datalake.models.PathAccessControl;
75+
import com.azure.storage.file.datalake.models.PathPermissions;
6776
```
6877

69-
4. Use the following snippet in your Java application to obtain token for the Active Directory Web application you created earlier using one of the subclasses of `AccessTokenProvider` (the following example uses `ClientCredsTokenProvider`). The token provider caches the creds used to obtain the token in memory, and automatically renews the token if it is about to expire. It is possible to create your own subclasses of `AccessTokenProvider` so tokens are obtained by your customer code. For now, let's just use the one provided in the SDK.
78+
4. Use the following snippet in your Java app to obtain a token for the Active Directory web app you created earlier using one of the class of `StorageSharedKeyCredential` (the following example uses `credential`). The token provider caches the credentials used to obtain the token in memory, and automatically renews the token if it's about to expire. It's possible to create your own subclasses of `StorageSharedKeyCredential` so tokens are obtained by your customer code. For now, let's just use the one provided in the SDK.
7079

7180
Replace **FILL-IN-HERE** with the actual values for the Azure Active Directory Web application.
7281

7382
```java
74-
private static String clientId = "FILL-IN-HERE";
75-
private static String authTokenEndpoint = "FILL-IN-HERE";
76-
private static String clientKey = "FILL-IN-HERE";
77-
78-
AccessTokenProvider provider = new ClientCredsTokenProvider(authTokenEndpoint, clientId, clientKey);
83+
private static String clienttId = "FILL-IN-HERE";
84+
private static String tenantId = "FILL-IN-HERE";
85+
private static String clientSecret = "FILL-IN-HERE";
86+
87+
ClientSecretCredential credential = new ClientSecretCredentialBuilder().clientId(clientId).tenantId(tenantId).clientSecret(clientSecret).build();
7988
```
8089

81-
The Data Lake Storage Gen1 SDK provides convenient methods that let you manage the security tokens needed to talk to the Data Lake Storage Gen1 account. However, the SDK does not mandate that only these methods be used. You can use any other means of obtaining token as well, like using the [Azure Active Directory SDK](https://github.com/AzureAD/azure-activedirectory-library-for-java), or your own custom code.
90+
The Data Lake Storage Gen2 SDK provides convenient methods that let you manage the security tokens needed to talk to the Data Lake Storage Gen2 account. However, the SDK doesn't mandate that only these methods be used. You can use any other means of obtaining token as well, like using the [Azure Identity client library](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity) or your own custom code.
8291

8392
## Next steps
8493

85-
In this article, you learned how to use end-user authentication to authenticate with Data Lake Storage Gen1 using Java SDK. You can now look at the following articles that talk about how to use the Java SDK to work with Data Lake Storage Gen1.
94+
In this article, you learned how to use end-user authentication to authenticate with Data Lake Storage Gen2 using Java SDK. You can now look at the following articles that talk about how to use the Java SDK to work with Data Lake Storage Gen2.
8695

87-
* [Data operations on Data Lake Storage Gen1 using Java SDK](data-lake-store-get-started-java-sdk.md)
96+
* [Data operations on Data Lake Storage Gen2 using Java SDK](data-lake-store-get-started-java-sdk.md)

0 commit comments

Comments
 (0)