Skip to content

Commit 83d5568

Browse files
More updates
1 parent f150e3a commit 83d5568

File tree

2 files changed

+52
-49
lines changed

2 files changed

+52
-49
lines changed

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: pauljewellmsft
66

77
ms.author: pauljewell
88
ms.service: azure-data-lake-storage
9-
ms.date: 02/07/2023
9+
ms.date: 09/06/2024
1010
ms.topic: how-to
1111
ms.reviewer: prishet
1212
ms.devlang: javascript
@@ -21,57 +21,61 @@ This article shows you how to use Node.js to get, set, and update the access con
2121

2222
## Prerequisites
2323

24-
- An Azure subscription. For more information, see [Get Azure free trial](https://azure.microsoft.com/pricing/free-trial/).
25-
26-
- A storage account that has hierarchical namespace (HNS) enabled. Follow [these](create-data-lake-storage-account.md) instructions to create one.
27-
24+
- Azure subscription - [create one for free](https://azure.microsoft.com/free/).
25+
- Azure storage account that has hierarchical namespace (HNS) enabled. Follow [these instructions](create-data-lake-storage-account.md) to create one.
26+
- [Node.js LTS](https://nodejs.org/)
2827
- Azure CLI version `2.6.0` or higher.
29-
3028
- One of the following security permissions:
31-
32-
- A provisioned Microsoft Entra ID [security principal](../../role-based-access-control/overview.md#security-principal) that has been assigned the [Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner) role, scoped to the target container, storage account, parent resource group, or subscription..
33-
29+
- A provisioned Microsoft Entra ID [security principal](../../role-based-access-control/overview.md#security-principal) that has been assigned the [Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner) role, scoped to the target container, storage account, parent resource group, or subscription.
3430
- Owning user of the target container or directory to which you plan to apply ACL settings. To set ACLs recursively, this includes all child items in the target container or directory.
35-
36-
- Storage account key..
31+
- Storage account key.
3732

3833
## Set up your project
3934

40-
Install Data Lake client library for JavaScript by opening a terminal window, and then typing the following command.
35+
This section walks you through preparing a project to work with the Azure Data Lake Storage client library for JavaScript.
4136

42-
```javascript
37+
### Install packages
38+
39+
Install packages for the Azure Data Lake Storage and Azure Identity client libraries using the `npm install` command. The **@azure/identity** package is needed for passwordless connections to Azure services.
40+
41+
```bash
4342
npm install @azure/storage-file-datalake
43+
npm install @azure/identity
4444
```
4545

46-
Import the `storage-file-datalake` package by placing this statement at the top of your code file.
46+
### Load modules
47+
48+
Add the following code at the top of your file to load the required modules:
4749

4850
```javascript
4951
const {
5052
AzureStorageDataLake,
5153
DataLakeServiceClient,
5254
StorageSharedKeyCredential
5355
} = require("@azure/storage-file-datalake");
56+
57+
const { DefaultAzureCredential } = require('@azure/identity');
5458
```
5559

5660
## Connect to the account
5761

58-
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account.
62+
To run the code examples in this article, you need to create a [DataLakeServiceClient](/javascript/api/@azure/storage-file-datalake/datalakeserviceclient) instance that represents the storage account. You can authorize the client object with Microsoft Entra ID credentials or with an account key.
5963

6064
<a name='connect-by-using-azure-active-directory-ad'></a>
6165

62-
### Connect by using Microsoft Entra ID
66+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
67+
68+
You can use the [Azure identity client library for JavaScript](https://www.npmjs.com/package/@azure/identity) to authenticate your application with Microsoft Entra ID.
6369

6470
> [!NOTE]
6571
> If you're using Microsoft Entra ID to authorize access, then make sure that your security principal has been assigned the [Storage Blob Data Owner role](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner). To learn more about how ACL permissions are applied and the effects of changing them, see [Access control model in Azure Data Lake Storage](./data-lake-storage-access-control-model.md).
6672
67-
You can use the [Azure identity client library for JS](https://www.npmjs.com/package/@azure/identity) to authenticate your application with Microsoft Entra ID.
68-
6973
First, you'll have to assign one of the following [Azure role-based access control (Azure RBAC)](../../role-based-access-control/overview.md) roles to your security principal:
7074

71-
|Role|ACL setting capability|
72-
|--|--|
73-
|[Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner)|All directories and files in the account.|
74-
|[Storage Blob Data Contributor](../../role-based-access-control/built-in-roles.md#storage-blob-data-contributor)|Only directories and files owned by the security principal.|
75+
| Role | ACL setting capability |
76+
| --- | --- |
77+
| [Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner) | All directories and files in the account. |
78+
| [Storage Blob Data Contributor](../../role-based-access-control/built-in-roles.md#storage-blob-data-contributor) | Only directories and files owned by the security principal. |
7579

7680
Next, create a [DataLakeServiceClient](/javascript/api/@azure/storage-file-datalake/datalakeserviceclient) instance and pass in a new instance of the [DefaultAzureCredential](/javascript/api/@azure/identity/defaultazurecredential) class.
7781

@@ -87,9 +91,9 @@ function GetDataLakeServiceClientAD(accountName) {
8791
}
8892
```
8993

90-
To learn more about using **DefaultAzureCredential** to authorize access to data, see [Overview: Authenticate JavaScript apps to Azure using the Azure SDK](/azure/developer/javascript/sdk/authentication/overview).
94+
To learn more about using `DefaultAzureCredential` to authorize access to data, see [Overview: Authenticate JavaScript apps to Azure using the Azure SDK](/azure/developer/javascript/sdk/authentication/overview).
9195

92-
### Connect by using an account key
96+
### [Account key](#tab/account-key)
9397

9498
You can authorize access to data using your account access keys (Shared Key). This example creates a [DataLakeServiceClient](/javascript/api/@azure/storage-file-datalake/datalakeserviceclient) instance that is authorized with the account key.
9599

@@ -110,6 +114,8 @@ function GetDataLakeServiceClient(accountName, accountKey) {
110114

111115
[!INCLUDE [storage-shared-key-caution](../../../includes/storage-shared-key-caution.md)]
112116

117+
---
118+
113119
## Get and set a directory ACL
114120

115121
This example gets and then sets the ACL of a directory named `my-directory`. This example gives the owning user read, write, and execute permissions, gives the owning group only read and execute permissions, and gives all others read access.

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

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: pauljewellmsft
66

77
ms.author: pauljewell
88
ms.service: azure-data-lake-storage
9-
ms.date: 02/07/2023
9+
ms.date: 09/06/2024
1010
ms.topic: how-to
1111
ms.reviewer: prishet
1212
ms.devlang: python
@@ -23,69 +23,66 @@ ACL inheritance is already available for new child items that are created under
2323

2424
## Prerequisites
2525

26-
- An Azure subscription. For more information, see [Get Azure free trial](https://azure.microsoft.com/pricing/free-trial/).
27-
28-
- A storage account that has hierarchical namespace (HNS) enabled. Follow [these](create-data-lake-storage-account.md) instructions to create one.
29-
26+
- Azure subscription - [create one for free](https://azure.microsoft.com/free/).
27+
- Azure storage account that has hierarchical namespace (HNS) enabled. Follow [these instructions](create-data-lake-storage-account.md) to create one.
28+
- [Python](https://www.python.org/downloads/) 3.8+
3029
- Azure CLI version `2.6.0` or higher.
31-
3230
- One of the following security permissions:
33-
3431
- A provisioned Microsoft Entra ID [security principal](../../role-based-access-control/overview.md#security-principal) that has been assigned the [Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner) role, scoped to the target container, storage account, parent resource group, or subscription.
35-
3632
- Owning user of the target container or directory to which you plan to apply ACL settings. To set ACLs recursively, this includes all child items in the target container or directory.
37-
3833
- Storage account key.
3934

4035
## Set up your project
4136

42-
Install the Azure Data Lake Storage client library for Python by using [pip](https://pypi.org/project/pip/).
37+
This section walks you through preparing a project to work with the Azure Data Lake Storage client library for Python.
4338

44-
```
45-
pip install azure-storage-file-datalake
39+
From your project directory, install packages for the Azure Data Lake Storage and Azure Identity client libraries using the `pip install` command. The **azure-identity** package is needed for passwordless connections to Azure services.
40+
41+
```console
42+
pip install azure-storage-file-datalake azure-identity
4643
```
4744

48-
Add these import statements to the top of your code file.
45+
Then open your code file and add the necessary import statements. In this example, we add the following to our *.py* file:
4946

5047
```python
51-
from azure.storage.filedatalake import DataLakeServiceClient
5248
from azure.identity import DefaultAzureCredential
49+
from azure.storage.filedatalake import DataLakeServiceClient
5350
```
5451

5552
## Connect to the account
5653

57-
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account.
54+
To run the code examples in this article, you need to create a [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient) instance that represents the storage account. You can authorize the client object with Microsoft Entra ID credentials or with an account key.
5855

59-
<a name='connect-by-using-azure-active-directory-ad'></a>
56+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
6057

61-
### Connect by using Microsoft Entra ID
58+
You can use the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) to authenticate your application with Microsoft Entra ID.
6259

6360
> [!NOTE]
6461
> If you're using Microsoft Entra ID to authorize access, then make sure that your security principal has been assigned the [Storage Blob Data Owner role](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner). To learn more about how ACL permissions are applied and the effects of changing them, see [Access control model in Azure Data Lake Storage](./data-lake-storage-access-control-model.md).
6562
66-
You can use the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) to authenticate your application with Microsoft Entra ID.
63+
First, assign one of the following [Azure role-based access control (Azure RBAC)](../../role-based-access-control/overview.md) roles to your security principal:
6764

68-
First, you'll have to assign one of the following [Azure role-based access control (Azure RBAC)](../../role-based-access-control/overview.md) roles to your security principal:
69-
70-
|Role|ACL setting capability|
71-
|--|--|
72-
|[Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner)|All directories and files in the account.|
73-
|[Storage Blob Data Contributor](../../role-based-access-control/built-in-roles.md#storage-blob-data-contributor)|Only directories and files owned by the security principal.|
65+
| Role | ACL setting capability |
66+
| --- | --- |
67+
| [Storage Blob Data Owner](../../role-based-access-control/built-in-roles.md#storage-blob-data-owner) | All directories and files in the account. |
68+
| [Storage Blob Data Contributor](../../role-based-access-control/built-in-roles.md#storage-blob-data-contributor) | Only directories and files owned by the security principal. |
7469

7570
Next, create a [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient) instance and pass in a new instance of the [DefaultAzureCredential](/python/api/azure-identity/azure.identity.defaultazurecredential) class.
7671

7772
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_AuthorizeWithAAD":::
7873

7974
To learn more about using **DefaultAzureCredential** to authorize access to data, see [Overview: Authenticate Python apps to Azure using the Azure SDK](/azure/developer/python/sdk/authentication-overview).
8075

81-
### Connect by using an account key
76+
### [Account key](#tab/account-key)
8277

8378
You can authorize access to data using your account access keys (Shared Key). This example creates a [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient) instance that is authorized with the account key.
8479

8580
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_AuthorizeWithKey":::
8681

8782
[!INCLUDE [storage-shared-key-caution](../../../includes/storage-shared-key-caution.md)]
8883

84+
---
85+
8986
## Set ACLs
9087

9188
When you *set* an ACL, you **replace** the entire ACL including all of its entries. If you want to change the permission level of a security principal or add a new security principal to the ACL without affecting other existing entries, you should *update* the ACL instead. To update an ACL instead of replace it, see the [Update ACLs](#update-acls-recursively) section of this article.

0 commit comments

Comments
 (0)