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/storage/blobs/data-lake-storage-acl-javascript.md
+30-24Lines changed: 30 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: pauljewellmsft
6
6
7
7
ms.author: pauljewell
8
8
ms.service: azure-data-lake-storage
9
-
ms.date: 02/07/2023
9
+
ms.date: 09/06/2024
10
10
ms.topic: how-to
11
11
ms.reviewer: prishet
12
12
ms.devlang: javascript
@@ -21,57 +21,61 @@ This article shows you how to use Node.js to get, set, and update the access con
21
21
22
22
## Prerequisites
23
23
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/)
28
27
- Azure CLI version `2.6.0` or higher.
29
-
30
28
- 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.
34
30
- 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.
37
32
38
33
## Set up your project
39
34
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.
41
36
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
43
42
npm install @azure/storage-file-datalake
43
+
npm install @azure/identity
44
44
```
45
45
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:
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.
### [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.
63
69
64
70
> [!NOTE]
65
71
> 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).
66
72
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
-
69
73
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:
70
74
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.|
75
79
76
80
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.
77
81
@@ -87,9 +91,9 @@ function GetDataLakeServiceClientAD(accountName) {
87
91
}
88
92
```
89
93
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).
91
95
92
-
### Connect by using an accountkey
96
+
### [Account key](#tab/account-key)
93
97
94
98
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.
95
99
@@ -110,6 +114,8 @@ function GetDataLakeServiceClient(accountName, accountKey) {
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.
Copy file name to clipboardExpand all lines: articles/storage/blobs/data-lake-storage-acl-python.md
+22-25Lines changed: 22 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: pauljewellmsft
6
6
7
7
ms.author: pauljewell
8
8
ms.service: azure-data-lake-storage
9
-
ms.date: 02/07/2023
9
+
ms.date: 09/06/2024
10
10
ms.topic: how-to
11
11
ms.reviewer: prishet
12
12
ms.devlang: python
@@ -23,69 +23,66 @@ ACL inheritance is already available for new child items that are created under
23
23
24
24
## Prerequisites
25
25
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+
30
29
- Azure CLI version `2.6.0` or higher.
31
-
32
30
- One of the following security permissions:
33
-
34
31
- 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
-
36
32
- 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
-
38
33
- Storage account key.
39
34
40
35
## Set up your project
41
36
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.
43
38
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.
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:
49
46
50
47
```python
51
-
from azure.storage.filedatalake import DataLakeServiceClient
52
48
from azure.identity import DefaultAzureCredential
49
+
from azure.storage.filedatalake import DataLakeServiceClient
53
50
```
54
51
55
52
## Connect to the account
56
53
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.
### [Microsoft Entra ID (recommended)](#tab/entra-id)
60
57
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.
62
59
63
60
> [!NOTE]
64
61
> 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).
65
62
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:
67
64
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. |
74
69
75
70
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.
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).
80
75
81
-
### Connect by using an accountkey
76
+
### [Account key](#tab/account-key)
82
77
83
78
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.
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