Azure Storage Datalake client library for Python Samples
These are code samples that show common scenario operations with the Azure DataLake Storage client library.
Several DataLake Storage Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with DataLake Storage:
datalake_samples_service.py
- Examples for authenticating and operating on the client:- Instantiate DataLakeServiceClient using connection str
- Instantiate DataLakeServiceClient using AAD Credential
- Get user delegation key
- Create all kinds of clients from DataLakeServiceClient and operate on those clients
- List file systems
datalake_samples_access_control.py
- Examples for common DataLake Storage tasks:- Set up a file system
- Create a directory
- Set/Get access control for the directory
- Create files under the directory
- Set/Get access control for each file
- Delete file system
datalake_samples_upload_download.py
- Examples for authenticating and creating the client:- Set up a file system
- Create file
- Append data to the file
- Flush data to the file
- Download the uploaded data
- Delete file system
Prerequisites
- Python 3.6 later is required to use this package
- You must have an Azure subscription and an Azure storage account to run these samples.
Setup
- Install the Azure Storage Datalake client library for Python with pip:
pip install azure-storage-file-datalake --pre
- Clone or download this sample repository
- Open the sample folder in Visual Studio Code or your IDE of choice.
Running the samples
- Open a terminal window and
cd
to the directory that the samples are saved in. - Set the environment variables
STORAGE_ACCOUNT_NAME
andSTORAGE_ACCOUNT_KEY
with your own values. - run the file, eg.
python datalake_samples_upload_download.py
Next steps
Check out the API reference documentation to learn more about what you can do with the DataLake Storage client library.