Azure Data Lake Storage Gen2 Filesystem¶
The Azure Data Lake Storage Gen2 filesystem provides access to ADLS Gen2 through Airflow’s ObjectStoragePath interface.
Supported URL formats:
abfs://connection_id@container/path/to/fileabfss://connection_id@container/path/to/fileadl://connection_id@container/path/to/file
Connection Configuration¶
Create an ADLS Gen2 connection in Airflow with the following parameters:
Connection Type: adls
Host: Storage account name, for example
mystorageaccount. For a private endpoint or custom domain, setaccount_hostin Extra (see below) rather than a full URL here.Login: Client ID for Active Directory authentication
Password: Client secret for Active Directory authentication, or account key for shared key authentication
The connection form provides additional configuration fields:
tenant_id: Tenant ID for Active Directory authenticationconnection_string: ADLS Gen2 connection string; this takes precedence over other authentication fieldsmanaged_identity_client_id: Client ID of a user-assigned managed identityworkload_identity_tenant_id: Tenant ID for workload identity authentication
The following keys are also supported in the connection’s Extra JSON:
account_name: Optional explicit storage account name overrideaccount_host: Optional custom storage account host, for private endpoints or custom domains
Examples¶
Read from ADLS Gen2 with ObjectStoragePath:
from airflow.sdk import ObjectStoragePath
path = ObjectStoragePath("abfs://adls_default@raw/events.json")
content = path.read_text()
Write to ADLS Gen2:
from airflow.sdk import ObjectStoragePath
output_path = ObjectStoragePath("abfss://adls_default@processed/events.json")
output_path.write_text('{"status": "ok"}')
Requirements¶
The Azure Data Lake Storage Gen2 filesystem requires the adlfs Python package.