Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python program to write a file into Microsoft Azure Data Lake Storage (ADLS Gen2) file system. For more details, refer to
from import DataLakeServiceClient
# install the following package
# pip install azure-storage-file-datalake
# Get the below details from your storage account
storage_account_name = ""
storage_account_key = ""
container_name = ""
directory_name = ""
service_client = DataLakeServiceClient(account_url="{}://{}".format(
"https", storage_account_name), credential=storage_account_key)
file_system_client = service_client.get_file_system_client(file_system=container_name)
dir_client = file_system_client.get_directory_client(directory_name)
data = """
Sample data for testing.
This is a multiline text for testing the ADLS Gen2 file system operations.
file_client = dir_client.create_file("sampledata.txt")
file_client.append_data(data, 0, len(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment