Skip to content

Commit 3c916a1

Browse files
authored
Merge pull request #108399 from normesta/normesta-sdk-interop
Adding Azure AD login
2 parents 3d45b20 + 4f1e52a commit 3c916a1

4 files changed

+138
-46
lines changed

articles/storage/blobs/data-lake-storage-directory-file-acl-dotnet.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
---
2-
title: Azure Data Lake Storage Gen2 .NET SDK for files & ACLs (preview)
2+
title: Azure Data Lake Storage Gen2 .NET SDK for files & ACLs
33
description: Use the Azure Storage client library to manage directories and file and directory access control lists (ACL) in storage accounts that has hierarchical namespace (HNS) enabled.
44
author: normesta
55
ms.service: storage
6-
ms.date: 03/18/2020
6+
ms.date: 03/20/2020
77
ms.author: normesta
88
ms.topic: article
99
ms.subservice: data-lake-storage-gen2
1010
ms.reviewer: prishet
1111
---
1212

13-
# Use .NET to manage directories, files, and ACLs in Azure Data Lake Storage Gen2 (preview)
13+
# Use .NET to manage directories, files, and ACLs in Azure Data Lake Storage Gen2
1414

1515
This article shows you how to use .NET to create and manage directories, files, and permissions in storage accounts that has hierarchical namespace (HNS) enabled.
1616

17-
> [!IMPORTANT]
18-
> The [Azure.Storage.Files.DataLake](https://www.nuget.org/packages/Azure.Storage.Files.DataLake) NuGet package that is featured in this article is currently in public preview.
19-
2017
[Package (NuGet)](https://www.nuget.org/packages/Azure.Storage.Files.DataLake) | [Samples](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/storage/Azure.Storage.Files.DataLake) | [API reference](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake) | [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/storage/Azure.Storage.Files.DataLake/GEN1_GEN2_MAPPING.md) | [Give Feedback](https://github.com/Azure/azure-sdk-for-net/issues)
2118

2219
## Prerequisites
@@ -43,9 +40,13 @@ using Azure;
4340

4441
## Connect to the account
4542

46-
To use the snippets in this article, you'll need to create a [DataLakeServiceClient](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakeserviceclient) instance that represents the storage account. The easiest way to get one is to use an account key.
43+
To use the snippets in this article, you'll need to create a [DataLakeServiceClient](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakeserviceclient) instance that represents the storage account.
44+
45+
### Connect by using an account key
46+
47+
This is the easiest way to connect to an account.
4748

48-
This example creates an instance of the [DataLakeServiceClient](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakeserviceclient?) by using an account key.
49+
This example creates a [DataLakeServiceClient](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakeserviceclient?) instance by using an account key.
4950

5051
```cs
5152
public void GetDataLakeServiceClient(ref DataLakeServiceClient dataLakeServiceClient,
@@ -61,6 +62,30 @@ public void GetDataLakeServiceClient(ref DataLakeServiceClient dataLakeServiceCl
6162
}
6263
```
6364

65+
### Connect by using Azure Active Directory (AD)
66+
67+
You can use the [Azure identity client library for .NET](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/identity/Azure.Identity) to authenticate your application with Azure AD.
68+
69+
This example creates a [DataLakeServiceClient](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakeserviceclient?) instance by using a client ID, a client secret, and a tenant ID. To get these values, see [Acquire a token from Azure AD for authorizing requests from a client application](../common/storage-auth-aad-app.md).
70+
71+
```cs
72+
public void GetDataLakeServiceClient(ref DataLakeServiceClient dataLakeServiceClient,
73+
String accountName, String clientID, string clientSecret, string tenantID)
74+
{
75+
76+
TokenCredential credential = new ClientSecretCredential(
77+
tenantID, clientID, clientSecret, new TokenCredentialOptions());
78+
79+
string dfsUri = "https://" + accountName + ".dfs.core.windows.net";
80+
81+
dataLakeServiceClient = new DataLakeServiceClient(new Uri(dfsUri), credential);
82+
}
83+
84+
```
85+
86+
> [!NOTE]
87+
> For more examples, see the [Azure identity client library for .NET](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/identity/Azure.Identity) documentation..
88+
6489
## Create a file system
6590

6691
A file system acts as a container for your files. You can create one by calling the [DataLakeServiceClient.CreateFileSystem](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakeserviceclient.createfilesystemasync) method.
@@ -198,13 +223,13 @@ public async Task UploadFile(DataLakeFileSystemClient fileSystemClient)
198223
```
199224

200225
> [!TIP]
201-
> If your file size is large, your code will have to make multiple calls to the [DataLakeFileClient.AppendAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.appendasync). Consider using the [DataLakeFileClient.UploadAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.uploadasync?view=azure-dotnet-preview#Azure_Storage_Files_DataLake_DataLakeFileClient_UploadAsync_System_IO_Stream_) method instead. That way, you can upload the entire file in a single call.
226+
> If your file size is large, your code will have to make multiple calls to the [DataLakeFileClient.AppendAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.appendasync). Consider using the [DataLakeFileClient.UploadAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.uploadasync?view=azure-dotnet#Azure_Storage_Files_DataLake_DataLakeFileClient_UploadAsync_System_IO_Stream_) method instead. That way, you can upload the entire file in a single call.
202227
>
203228
> See the next section for an example.
204229
205230
## Upload a large file to a directory
206231

207-
Use the [DataLakeFileClient.UploadAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.uploadasync?view=azure-dotnet-preview#Azure_Storage_Files_DataLake_DataLakeFileClient_UploadAsync_System_IO_Stream_) method to upload large files without having to make multiple calls to the [DataLakeFileClient.AppendAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.appendasync) method.
232+
Use the [DataLakeFileClient.UploadAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.uploadasync?view=azure-dotnet#Azure_Storage_Files_DataLake_DataLakeFileClient_UploadAsync_System_IO_Stream_) method to upload large files without having to make multiple calls to the [DataLakeFileClient.AppendAsync](https://docs.microsoft.com/dotnet/api/azure.storage.files.datalake.datalakefileclient.appendasync) method.
208233

209234
```cs
210235
public async Task UploadFileBulk(DataLakeFileSystemClient fileSystemClient)

articles/storage/blobs/data-lake-storage-directory-file-acl-java.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
---
2-
title: Azure Data Lake Storage Gen2 Java SDK for files & ACLs (preview)
2+
title: Azure Data Lake Storage Gen2 Java SDK for files & ACLs
33
description: Use Azure Storage libraries for Java to manage directories and file and directory access control lists (ACL) in storage accounts that has hierarchical namespace (HNS) enabled.
44
author: normesta
55
ms.service: storage
6-
ms.date: 03/18/2020
6+
ms.date: 03/20/2020
77
ms.author: normesta
88
ms.topic: conceptual
99
ms.subservice: data-lake-storage-gen2
1010
ms.reviewer: prishet
1111
---
1212

13-
# Use Java to manage directories, files, and ACLs in Azure Data Lake Storage Gen2 (preview)
13+
# Use Java to manage directories, files, and ACLs in Azure Data Lake Storage Gen2
1414

1515
This article shows you how to use Java to create and manage directories, files, and permissions in storage accounts that has hierarchical namespace (HNS) enabled.
1616

17-
> [!IMPORTANT]
18-
> The Java library that is featured in this article is currently in public preview.
19-
20-
[Package (Maven)](https://search.maven.org/artifact/com.azure/azure-storage-file-datalake) | [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-file-datalake) | [API reference](https://azuresdkdocs.blob.core.windows.net/$web/java/azure-storage-file-datalake/12.0.0-preview.6/index.html) | [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-file-datalake/GEN1_GEN2_MAPPING.md) | [Give Feedback](https://github.com/Azure/azure-sdk-for-java/issues)
17+
[Package (Maven)](https://search.maven.org/artifact/com.azure/azure-storage-file-datalake) | [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-file-datalake) | [API reference](https://azuresdkdocs.blob.core.windows.net/$web/java/azure-storage-file-datalake/12.0.1/index.html) | [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-file-datalake/GEN1_GEN2_MAPPING.md) | [Give Feedback](https://github.com/Azure/azure-sdk-for-java/issues)
2118

2219
## Prerequisites
2320

@@ -49,19 +46,15 @@ import com.azure.storage.file.datalake.models.PathPermissions;
4946
import com.azure.storage.file.datalake.models.RolePermissions;
5047
```
5148

52-
If you plan to authenticate your client application by using Azure AD, then add these imports statements to your code file.
49+
## Connect to the account
5350

54-
```java
55-
import com.azure.identity.ClientSecretCredential;
56-
import com.azure.identity.ClientSecretCredentialBuilder;
57-
import com.azure.core.credential.TokenCredential;
58-
````
51+
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account.
5952

60-
## Connect to the account
53+
### Connect by using an account key
6154

62-
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account. The easiest way to get one is to use an account key.
55+
This is the easiest way to connect to an account.
6356

64-
This example creates an instance of the **DataLakeServiceClient** by using an account key.
57+
This example creates a **DataLakeServiceClient** instance by using an account key.
6558

6659
```java
6760

@@ -78,8 +71,35 @@ static public DataLakeServiceClient GetDataLakeServiceClient
7871

7972
return builder.buildClient();
8073
}
74+
```
75+
76+
### Connect by using Azure Active Directory (Azure AD)
77+
78+
You can use the [Azure identity client library for Java](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/identity/azure-identity) to authenticate your application with Azure AD.
8179

80+
This example creates a **DataLakeServiceClient** instance by using a client ID, a client secret, and a tenant ID. To get these values, see [Acquire a token from Azure AD for authorizing requests from a client application](../common/storage-auth-aad-app.md).
81+
82+
```java
83+
static public DataLakeServiceClient GetDataLakeServiceClient
84+
(String accountName, String clientId, String ClientSecret, String tenantID){
85+
86+
String endpoint = "https://" + accountName + ".dfs.core.windows.net";
87+
88+
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
89+
.clientId(clientId)
90+
.clientSecret(ClientSecret)
91+
.tenantId(tenantID)
92+
.build();
93+
94+
DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder();
95+
return builder.credential(clientSecretCredential).endpoint(endpoint).buildClient();
96+
}
8297
```
98+
99+
> [!NOTE]
100+
> For more examples, see the [Azure identity client library for Java](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/identity/azure-identity) documentation.
101+
102+
83103
## Create a file system
84104

85105
A file system acts as a container for your files. You can create one by calling the **DataLakeServiceClient.createFileSystem** method.
@@ -367,8 +387,8 @@ static public void ListFilesInDirectory(DataLakeFileSystemClient fileSystemClien
367387

368388
## See also
369389

370-
* [API reference documentation](https://azuresdkdocs.blob.core.windows.net/$web/java/azure-storage-file-datalake/12.0.0-preview.6/index.html)
371-
* [Package (Maven)](https://search.maven.org/artifact/com.azure/azure-storage-file-datalake/12.0.0-preview.6/jar)
390+
* [API reference documentation](https://azuresdkdocs.blob.core.windows.net/$web/java/azure-storage-file-datalake/12.0.1/index.html)
391+
* [Package (Maven)](https://search.maven.org/artifact/com.azure/azure-storage-file-datalake)
372392
* [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-file-datalake)
373393
* [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/azure-storage-file-datalake/GEN1_GEN2_MAPPING.md)
374394
* [Known issues](data-lake-storage-known-issues.md#api-scope-data-lake-client-library)

articles/storage/blobs/data-lake-storage-directory-file-acl-javascript.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
---
2-
title: Use JavaScript for files & ACLs in Azure Data Lake Storage Gen2 (preview)
2+
title: Use JavaScript for files & ACLs in Azure Data Lake Storage Gen2
33
description: Use Azure Storage Data Lake client library for JavaScript to manage directories and file and directory access control lists (ACL) in storage accounts that has hierarchical namespace (HNS) enabled.
44
author: normesta
55
ms.service: storage
6-
ms.date: 03/18/2020
6+
ms.date: 03/20/2020
77
ms.author: normesta
88
ms.topic: conceptual
99
ms.subservice: data-lake-storage-gen2
1010
ms.reviewer: prishet
1111
---
1212

13-
# Use JavaScript to manage directories, files, and ACLs in Azure Data Lake Storage Gen2 (preview)
13+
# Use JavaScript to manage directories, files, and ACLs in Azure Data Lake Storage Gen2
1414

1515
This article shows you how to use JavaScript to create and manage directories, files, and permissions in storage accounts that has hierarchical namespace (HNS) enabled.
1616

17-
> [!IMPORTANT]
18-
> The JavaScript library that is featured in this article is currently in public preview.
19-
2017
[Package (Node Package Manager)](https://www.npmjs.com/package/@azure/storage-file-datalake) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage/storage-file-datalake/samples) | [Give Feedback](https://github.com/Azure/azure-sdk-for-java/issues)
2118

2219
## Prerequisites
@@ -42,9 +39,13 @@ const AzureStorageDataLake = require("@azure/storage-file-datalake");
4239

4340
## Connect to the account
4441

45-
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account. The easiest way to get one is to use an account key.
42+
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account.
43+
44+
### Connect by using an account key
45+
46+
This is the easiest way to connect to an account.
4647

47-
This example creates an instance of the **DataLakeServiceClient** by using an account key.
48+
This example creates a **DataLakeServiceClient** instance by using an account key.
4849

4950
```javascript
5051

@@ -61,7 +62,28 @@ function GetDataLakeServiceClient(accountName, accountKey) {
6162

6263
```
6364
> [!NOTE]
64-
> This method of authorization works only for Node.js applications. If you plan to run your code in a browser, you can authorize by using Azure Active Directory (AD). For guidance on how to do that, see the [Azure Storage File Data Lake client library for JavaScript](https://www.npmjs.com/package/@azure/storage-file-datalake) readme file.
65+
> This method of authorization works only for Node.js applications. If you plan to run your code in a browser, you can authorize by using Azure Active Directory (AD).
66+
67+
### Connect by using Azure Active Directory (AD)
68+
69+
You can use the [Azure identity client library for JS](https://www.npmjs.com/package/@azure/identity) to authenticate your application with Azure AD.
70+
71+
This example creates a **DataLakeServiceClient** instance by using a client ID, a client secret, and a tenant ID. To get these values, see [Acquire a token from Azure AD for authorizing requests from a client application](../common/storage-auth-aad-app.md).
72+
73+
```javascript
74+
function GetDataLakeServiceClientAD(accountName, clientID, clientSecret, tenantID) {
75+
76+
const credential = new ClientSecretCredential(tenantID, clientID, clientSecret);
77+
78+
const datalakeServiceClient = new DataLakeServiceClient(
79+
`https://${accountName}.dfs.core.windows.net`, credential);
80+
81+
return datalakeServiceClient;
82+
}
83+
```
84+
85+
> [!NOTE]
86+
> For more examples, see the [Azure identity client library for JS](https://www.npmjs.com/package/@azure/identity) documentation.
6587
6688
## Create a file system
6789

articles/storage/blobs/data-lake-storage-directory-file-acl-python.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
---
2-
title: Azure Data Lake Storage Gen2 Python SDK for files & ACLs (preview)
2+
title: Azure Data Lake Storage Gen2 Python SDK for files & ACLs
33
description: Use Python manage directories and file and directory access control lists (ACL) in storage accounts that has hierarchical namespace (HNS) enabled.
44
author: normesta
55
ms.service: storage
6-
ms.date: 11/24/2019
6+
ms.date: 03/20/2020
77
ms.author: normesta
88
ms.topic: article
99
ms.subservice: data-lake-storage-gen2
1010
ms.reviewer: prishet
1111
---
1212

13-
# Use Python to manage directories, files, and ACLs in Azure Data Lake Storage Gen2 (preview)
13+
# Use Python to manage directories, files, and ACLs in Azure Data Lake Storage Gen2
1414

1515
This article shows you how to use Python to create and manage directories, files, and permissions in storage accounts that has hierarchical namespace (HNS) enabled.
1616

17-
> [!IMPORTANT]
18-
> The Azure Data Lake Storage client library for Python is currently in public preview.
19-
20-
[Package (Python Package Index)](https://pypi.org/project/azure-storage-file-datalake/) | [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-file-datalake/samples) | [API reference](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-file-datalake/12.0.0b5/index.html) | [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-file-datalake/GEN1_GEN2_MAPPING.md) | [Give Feedback](https://github.com/Azure/azure-sdk-for-python/issues)
17+
[Package (Python Package Index)](https://pypi.org/project/azure-storage-file-datalake/) | [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-file-datalake/samples) | [API reference](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-file-datalake/12.0.0/azure.storage.filedatalake.html) | [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-file-datalake/GEN1_GEN2_MAPPING.md) | [Give Feedback](https://github.com/Azure/azure-sdk-for-python/issues)
2118

2219
## Prerequisites
2320

@@ -44,9 +41,13 @@ from azure.storage.filedatalake._models import ContentSettings
4441

4542
## Connect to the account
4643

47-
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account. The easiest way to get one is to use an account key.
44+
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account.
45+
46+
### Connect by using an account key
4847

49-
This example uses an account key to create a **DataLakeServiceClient** instance that represents the storage account.
48+
This is the easiest way to connect to an account.
49+
50+
This example creates a **DataLakeServiceClient** instance by using an account key.
5051

5152
```python
5253
try:
@@ -63,6 +64,30 @@ except Exception as e:
6364

6465
- Replace the `storage_account_key` placeholder value with your storage account access key.
6566

67+
### Connect by using Azure Active Directory (AD)
68+
69+
You can use the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) to authenticate your application with Azure AD.
70+
71+
This example creates a **DataLakeServiceClient** instance by using a client ID, a client secret, and a tenant ID. To get these values, see [Acquire a token from Azure AD for authorizing requests from a client application](../common/storage-auth-aad-app.md).
72+
73+
```python
74+
def initialize_storage_account_ad(storage_account_name, client_id, client_secret, tenant_id):
75+
76+
try:
77+
global service_client
78+
79+
credential = ClientSecretCredential(tenant_id, client_id, client_secret)
80+
81+
service_client = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format(
82+
"https", storage_account_name), credential=credential)
83+
84+
except Exception as e:
85+
print(e)
86+
```
87+
88+
> [!NOTE]
89+
> For more examples, see the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) documentation.
90+
6691
## Create a file system
6792

6893
A file system acts as a container for your files. You can create one by calling the **FileSystemDataLakeServiceClient.create_file_system** method.

0 commit comments

Comments
 (0)