Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
yongshao
Helper III
Helper III

Fabric API to create ADLS gen2 connection

I've tried to create a connection to ADLS gen2 account, but always got the "request has an invalid input" error, could someone please provide a correct playload template?

 

import sempy.fabric as fabric
client = fabric.FabricRestClient()
payload = {
'displayName': 'TEST',
'connectivityType': 'ShareableCloud',
'connectionDetails':
{
'type': 'AzureDataLakeStorage',
"creationMethods": [
{

"parameters": [
{
"server": "ADLS gen2 account string"
},
{
"path": "/"
}
]
}
],
},
'privacyLevel': 'Organizational',
'credentialDetails':
{
'credentialType': 'Key',
'singleSignOnType': 'None',
'connectionEncryption': 'NotEncrypted',
'skipTestConnection': False,
'credentials':{
       'key': 'access key value'
}
}
}
response = client.post(f"/v1/connections/", json=payload)
3 REPLIES 3
yongshao
Helper III
Helper III

We can manually setup such connection via Fabric UI, but for production we have to use Fabric API to create a connection with ADLS gen2 account

 

I cannot find any payload template or format for such connection creation from https://learn.microsoft.com/en-us/rest/api/fabric/core/connections/create-connection?tabs=HTTP

it'll be helpful if you could provide the followings:

for SQL, it's 

 

"connectionDetails": {
    "type": "SQL",
    "creationMethod": "SQL"
}

 

 

what's the values of type and creationMethod for Azure Data Lake Storage Gen2?
 
for basic authentication, it's 

 

"credentials": {
      "credentialType": "Basic",
      "username": "admin",
      "password": "********"
    }

 

what's the syntax of credentials for Service principal authentication? 
Anonymous
Not applicable

Hi @yongshao,

Perhaps you can tried to use "tenant_id", "client_id","client_secret", "storage_account_name",
"container_name" and "file_path" as the configuration that use in requests:

import requests

# configuration
tenant_id = "your-tenant-id"
client_id = "your-client-id"
client_secret = "your-client-secret"
storage_account_name =  "your-storage-account-name"
container_name =  "your-container-name"
file_path = "path/to/your/file"

# Get an access token
url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
payload = {
    'grant_type': 'client_credentials',
    'client_id': client_id,
    'client_secret': client_secret,
    'scope': 'https://storage.azure.com/.default'
}
response = requests.post(url, data=payload)
access_token = response.json().get('access_token')

# Access data from Azure Data Lake Storage Gen2
storage_url = f"https://{storage_account_name}.dfs.core.windows.net/{container_name}/{file_path}"
headers = {
    'Authorization': f'Bearer {access_token}'
}
response = requests.get(storage_url, headers=headers)

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi @yongshao ,

Can you please share some more detail information about this issue? They should help us clarify your scenario and test to troubleshoot.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Fabric Update Carousel

Fabric Monthly Update - September 2025

Check out the September 2025 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.