Skip to content

Commit b578097

Browse files
authored
Merge pull request #221994 from vmagelo/freshness-work
Freshness work.
2 parents 4ebe98e + 3edc85b commit b578097

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Use Python to manage data in Azure Data Lake Storage Gen2
33
titleSuffix: Azure Storage
4-
description: Use Python to manage directories and files in storage accounts that has hierarchical namespace enabled.
4+
description: Use Python to manage directories and files in a storage account that has hierarchical namespace enabled.
55
author: pauljewellmsft
66

77
ms.author: pauljewell
88
ms.service: storage
9-
ms.date: 02/17/2021
9+
ms.date: 12/20/2022
1010
ms.topic: how-to
1111
ms.subservice: data-lake-storage-gen2
1212
ms.reviewer: prishet
@@ -26,7 +26,7 @@ To learn about how to get, set, and update the access control lists (ACL) of dir
2626

2727
- An Azure subscription. See [Get Azure free trial](https://azure.microsoft.com/pricing/free-trial/).
2828

29-
- A storage account that has hierarchical namespace enabled. Follow [these](create-data-lake-storage-account.md) instructions to create one.
29+
- A storage account that has [hierarchical namespace](./data-lake-storage-namespace.md) enabled. Follow [these](create-data-lake-storage-account.md) instructions to create one.
3030

3131
## Set up your project
3232

@@ -47,11 +47,11 @@ from azure.storage.filedatalake._models import ContentSettings
4747

4848
## Connect to the account
4949

50-
To use the snippets in this article, you'll need to create a **DataLakeServiceClient** instance that represents the storage account.
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.
5151

5252
### Connect by using an account key
5353

54-
This is the easiest way to connect to an account.
54+
Using an account key is the easiest way to connect to an account.
5555

5656
This example creates a **DataLakeServiceClient** instance by using an account key.
5757

@@ -65,71 +65,73 @@ This example creates a **DataLakeServiceClient** instance by using an account ke
6565

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

68-
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).
68+
This example creates a **DataLakeServiceClient** instance with a [ClientSecretCredential](/python/api/azure-identity/azure.identity.clientsecretcredential) credential. You create the credential object with a client ID, a client secret, and a tenant ID representing a security principal. To get these values, see [Authorize access to blob or queue data from a native or web application](../common/storage-auth-aad-app.md). Assign the **Storage Blob Data Contributor** role to the service principal.
6969

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

72+
To use this code, make sure you have an import statement for the **ClientSecretCredential**: `from azure.identity import ClientSecretCredential`.
73+
7274
> [!NOTE]
7375
> For more examples, see the [Azure identity client library for Python](https://pypi.org/project/azure-identity/) documentation.
7476
7577
## Create a container
7678

77-
A container acts as a file system for your files. You can create one by calling the **FileSystemDataLakeServiceClient.create_file_system** method.
79+
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).
7880

7981
This example creates a container named `my-file-system`.
8082

8183
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_CreateContainer":::
8284

8385
## Create a directory
8486

85-
Create a directory reference by calling the **FileSystemClient.create_directory** method.
87+
Create a directory reference by calling the [FileSystemClient.create_directory](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.filesystemclient#azure-storage-filedatalake-filesystemclient-create-directory) method.
8688

8789
This example adds a directory named `my-directory` to a container.
8890

8991
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_CreateDirectory":::
9092

9193
## Rename or move a directory
9294

93-
Rename or move a directory by calling the **DataLakeDirectoryClient.rename_directory** method. Pass the path of the desired directory a parameter.
95+
Rename or move a directory by calling the [DataLakeDirectoryClient.rename_directory](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakedirectoryclient#azure-storage-filedatalake-datalakedirectoryclient-rename-directory) method. Pass the path of the desired directory a parameter.
9496

95-
This example renames a sub-directory to the name `my-directory-renamed`.
97+
This example renames a subdirectory to the name `my-directory-renamed`.
9698

9799
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_RenameDirectory":::
98100

99101
## Delete a directory
100102

101-
Delete a directory by calling the **DataLakeDirectoryClient.delete_directory** method.
103+
Delete a directory by calling the [DataLakeDirectoryClient.delete_directory](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakedirectoryclient#azure-storage-filedatalake-datalakedirectoryclient-delete-directory) method.
102104

103105
This example deletes a directory named `my-directory`.
104106

105107
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_DeleteDirectory":::
106108

107109
## Upload a file to a directory
108110

109-
First, create a file reference in the target directory by creating an instance of the **DataLakeFileClient** class. Upload a file by calling the **DataLakeFileClient.append_data** method. Make sure to complete the upload by calling the **DataLakeFileClient.flush_data** method.
111+
First, create a file reference in the target directory by creating an instance of the **DataLakeFileClient** class. Upload a file by calling the [DataLakeFileClient.append_data](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-append-data) method. Make sure to complete the upload by calling the [DataLakeFileClient.flush_data](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-flush-data) method.
110112

111113
This example uploads a text file to a directory named `my-directory`.
112114

113115
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_UploadFile":::
114116

115117
> [!TIP]
116-
> If your file size is large, your code will have to make multiple calls to the **DataLakeFileClient.append_data** method. Consider using the **DataLakeFileClient.upload_data** method instead. That way, you can upload the entire file in a single call.
118+
> If your file size is large, your code will have to make multiple calls to the **DataLakeFileClient** [append_data](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-append-data) method. Consider using the [upload_data](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-upload-data) method instead. That way, you can upload the entire file in a single call.
117119
118120
## Upload a large file to a directory
119121

120-
Use the **DataLakeFileClient.upload_data** method to upload large files without having to make multiple calls to the **DataLakeFileClient.append_data** method.
122+
Use the [DataLakeFileClient.upload_data](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-upload-data) method to upload large files without having to make multiple calls to the [DataLakeFileClient.append_data](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-append-data) method.
121123

122124
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_UploadFileBulk":::
123125

124126
## Download from a directory
125127

126-
Open a local file for writing. Then, create a **DataLakeFileClient** instance that represents the file that you want to download. Call the **DataLakeFileClient.read_file** to read bytes from the file and then write those bytes to the local file.
128+
Open a local file for writing. Then, create a **DataLakeFileClient** instance that represents the file that you want to download. Call the [DataLakeFileClient.download_file](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient#azure-storage-filedatalake-datalakefileclient-download-file) to read bytes from the file and then write those bytes to the local file.
127129

128130
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/python-v12/crud_datalake.py" id="Snippet_DownloadFromDirectory":::
129131

130132
## List directory contents
131133

132-
List directory contents by calling the **FileSystemClient.get_paths** method, and then enumerating through the results.
134+
List directory contents by calling the [FileSystemClient.get_paths](/python/api/azure-storage-file-datalake/azure.storage.filedatalake.filesystemclient#azure-storage-filedatalake-filesystemclient-get-paths) method, and then enumerating through the results.
133135

134136
This example, prints the path of each subdirectory and file that is located in a directory named `my-directory`.
135137

@@ -138,7 +140,7 @@ This example, prints the path of each subdirectory and file that is located in a
138140
## See also
139141

140142
- [API reference documentation](/python/api/azure-storage-file-datalake/azure.storage.filedatalake)
141-
- [Package (Python Package Index)](https://pypi.org/project/azure-storage-file-datalake/)
143+
- [Azure File Data Lake Storage Client Library (Python Package Index)](https://pypi.org/project/azure-storage-file-datalake/)
142144
- [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-file-datalake/samples)
143145
- [Gen1 to Gen2 mapping](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-file-datalake/GEN1_GEN2_MAPPING.md)
144146
- [Known issues](data-lake-storage-known-issues.md#api-scope-data-lake-client-library)

0 commit comments

Comments
 (0)