使用服务主体连接到 ADLS Gen 2

Connecting to ADLS Gen 2 using Service Principals

任何人都可以显示任何 python 代码我可以使用服务主体连接到 ADLS Gen 2

首先,安装以下库:

azure-storage-file-datalake

azure-identity

然后使用下面的代码:

from azure.storage.filedatalake import DataLakeServiceClient
from azure.identity import ClientSecretCredential

tenant_id="xxx"
client_id="xxx"
client_secret="xxx"

credential = ClientSecretCredential(tenant_id,client_id,client_secret)
service = DataLakeServiceClient(account_url="https://xxx.dfs.core.windows.net/",credential=credential)

#create a file system in ADLS Gen2
file_system_client = service.create_file_system(file_system="myfileSystem")

更多代码示例是here.