Forum Discussion
FABRIC REST API Connections - Create Connection
Does anyone know how to run this API via a PowerShell script to create a SQL Server cloud connection for a semantic model using Service Principal authentication?
Here's what I have so far:
Invoke-PowerBIRestMethod -Url "https://api.fabric.microsoft.com/v1/connections" -Method Post -Body $body
But I don't understand how to construct the body
Thanks in Advance,
Charline
2 Replies
- Prince0011
Solution Sage
Hi,
Here's a working body structure for SQL Server + Service Principal:
$body = @{
connectivityType = "ShareableCloud"
displayName = "SQL Server Connection"
connectionDetails = @{
type = "SQL"
creationMethod = "SQL"
parameters = @(
@{ dataType = "Text"; name = "server"; value = "yourserver.database.windows.net" },
@{ dataType = "Text"; name = "database"; value = "yourdatabase" }
)
}
privacyLevel = "Organizational"
credentialDetails = @{
credentialType = "ServicePrincipal"
credentials = @{
tenantId = "your-tenant-id"
servicePrincipalClientId = "your-client-id"
servicePrincipalSecret = "your-client-secret"
}
singleSignOnType = "None"
connectionEncryption = "Encrypted"
skipTestConnection = $false
}
} | ConvertTo-Json -Depth 10
Call it against api.fabric.microsoft.com directly, double check field casing against current docs since it's picky.
If this helped, feel free to give it a kudos or mark it as solution, helps others find it too.
- v-sathmakuri
Community Support
Hi Charline_74 ,
Could you review the suggestion provided above and let us know if you have any additional questions, we are happy to address.
Thanks!!