Reputation: 984
Can anyone show any python code I can use to connect to ADLS Gen 2 using Service principals
Upvotes: 1
Views: 1965
Reputation: 29985
First, install the following libraries:
Then use the code below:
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")
More code examples are here.
Upvotes: 2