Skip to content

Commit b116efb

Browse files
authored
Merge pull request #228168 from pauljewellmsft/pauljewell-adls-py
Update setup and auth sections
2 parents 715ef8e + 3bfdfc4 commit b116efb

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,58 @@ To learn about how to get, set, and update the access control lists (ACL) of dir
3030

3131
## Set up your project
3232

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.
3434

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.
36+
37+
```console
38+
pip install azure-storage-file-datalake azure-identity
3739
```
3840

39-
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:
4042

4143
```python
4244
import os, uuid, sys
45+
from azure.identity import DefaultAzureCredential
4346
from azure.storage.filedatalake import DataLakeServiceClient
4447
from azure.core._match_conditions import MatchConditions
4548
from azure.storage.filedatalake._models import ContentSettings
4649
```
4750

48-
## Connect to the account
51+
## Authorize access and connect to data resources
4952

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).
5154

52-
### Connect by using Azure Active Directory (Azure AD)
55+
### [Azure AD](#tab/azure-ad)
5356

5457
You can use the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) to authenticate your application with Azure AD.
5558

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.
5760

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

60-
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.
6168

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).
69+
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_AuthorizeWithSAS":::
6370

64-
### Connect by using an account key
71+
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)
6576

6677
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.
6778

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

7081
[!INCLUDE [storage-shared-key-caution](../../../includes/storage-shared-key-caution.md)]
7182

83+
---
84+
7285
## Create a container
7386

7487
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).

articles/storage/blobs/storage-blob-delete-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The following code example gets the latest version of a deleted blob, and restor
8181

8282
3. The following code deletes a directory, and then restores a soft-deleted directory.
8383

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).
8585

8686
```python
8787
def restoreDirectory():

0 commit comments

Comments
 (0)