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-directory-file-acl-python.md
+24-11Lines changed: 24 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,45 +30,58 @@ To learn about how to get, set, and update the access control lists (ACL) of dir
30
30
31
31
## Set up your project
32
32
33
-
Install the Azure Data Lake Storage client library for Python by using [pip](https://pypi.org/project/pip/).
33
+
This section walks you through preparing a project to work with the Azure Data Lake Storage client library for Python.
34
34
35
-
```
36
-
pip install azure-storage-file-datalake
35
+
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.
41
+
Then open your code file and add the necessary import statements. In this example, we add the following to our *.py* file:
40
42
41
43
```python
42
44
import os, uuid, sys
45
+
from azure.identity import DefaultAzureCredential
43
46
from azure.storage.filedatalake import DataLakeServiceClient
44
47
from azure.core._match_conditions import MatchConditions
45
48
from azure.storage.filedatalake._models import ContentSettings
46
49
```
47
50
48
-
## Connect to the account
51
+
## Authorize access and connect to data resources
49
52
50
-
To use the snippets in this article, you'll need to create a [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient) instance that represents the storage account.
53
+
To work with the code examples in this article, you need to create an authorized [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient) instance that represents the storage account. You can authorize a `DataLakeServiceClient` using Azure Active Directory (Azure AD), an account access key, or a shared access signature (SAS).
51
54
52
-
### Connect by using Azure Active Directory (Azure AD)
55
+
### [Azure AD](#tab/azure-ad)
53
56
54
57
You can use the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) to authenticate your application with Azure AD.
55
58
56
-
Create an [azure.storage.filedatalake.DataLakeServiceClient class](/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.
59
+
Create an instance of the [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient)class and pass in a [DefaultAzureCredential](/python/api/azure-identity/azure.identity.defaultazurecredential)object.
To use this code, make sure you have an import statement for the **ClientSecretCredential**: `from azure.identity import ClientSecretCredential`.
63
+
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).
64
+
65
+
### [SAS token](#tab/sas-token)
66
+
67
+
To use a shared access signature (SAS) token, provide the token as a string and initialize a [DataLakeServiceClient](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient) object. If your account URL includes the SAS token, omit the credential parameter.
61
68
62
-
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).
To learn more about generating and managing SAS tokens, see the following article:
72
+
73
+
-[Grant limited access to Azure Storage resources using shared access signatures (SAS)](../common/storage-sas-overview.md?toc=/azure/storage/blobs/toc.json)
74
+
75
+
### [Account key](#tab/account-key)
65
76
66
77
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.
A container acts as a file system for your files. You can create one by calling the [DataLakeServiceClient.create_file_system method](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakeserviceclient#azure-storage-filedatalake-datalakeserviceclient-create-file-system).
Copy file name to clipboardExpand all lines: articles/storage/blobs/storage-blob-delete-python.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ The following code example gets the latest version of a deleted blob, and restor
81
81
82
82
3. The following code deletes a directory, and then restores a soft-deleted directory.
83
83
84
-
The code example below contains an object named `service_client` of type **DataLakeServiceClient**. To see examples of how to create a **DataLakeServiceClient** instance, see [Connect to the account](data-lake-storage-directory-file-acl-python.md#connect-to-the-account).
84
+
The code example below contains an object named `service_client` of type **DataLakeServiceClient**. To see examples of how to create a **DataLakeServiceClient** instance, see [Authorize access and connect to data resources](data-lake-storage-directory-file-acl-python.md#authorize-access-and-connect-to-data-resources).
0 commit comments