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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
gb_asc
Regular Visitor

Programmatically create a Power BI dataset with data source connections

Hi all,

 

I am trying to create a power bi dataset through Python or C# (TOM library).  The goal is to:

1) Create a power bi dataset with SQL Server as the source. Attach the datasource connetcion strings to the tables in the dataset.
2) Push it to Power BI Service using XMLA End Points

I managed to create the dataset using REST API (Push Dataset), but not able to attach the datasource credentials.


Has anyone managed to do this?



Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @gb_asc,

Thank you for reaching out in Microsoft Community Forum.

Thank you @Deku , @lbendlin  for the helpful response.

Please follow below steps to Programmatically create a Power BI dataset with data source connections;

1.Define your model with SQL Server as the source using the Microsoft.AnalysisServices.Tabular library.

2.Connect to the Power BI workspace using the XMLA endpoint and deploy the dataset.

3.Use the Power BI Admin REST API to set data source credentials after deployment (XMLA doesn't support credential input).

4. Make sure you authenticate with a gateway or service principal to securely manage credentials.

Please continue using Microsoft community forum.

If you found this post helpful, please consider marking it as "Accept as Solution" and give it a 'Kudos'. if it was helpful. help other members find it more easily.

Regards,
Pavan.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @gb_asc,

I wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.
If the community member's answer your query, please mark it as "Accept as Solution" and select "Yes" if it was helpful.
If you need any further assistance, feel free to reach out.

Please continue using Microsoft community forum.

Thank you,
Pavan.

Anonymous
Not applicable

Hi @gb_asc,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, kindly "Accept  as  Solution" and give it a 'Kudos' so others can find it easily.

Thank you,
Pavan.

Anonymous
Not applicable

Hi @gb_asc,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please "Accept  as  Solution" and give a 'Kudos' so other members can easily find it.

Thank you,
Pavan.

Anonymous
Not applicable

Hi @gb_asc,

Thank you for reaching out in Microsoft Community Forum.

Thank you @Deku , @lbendlin  for the helpful response.

Please follow below steps to Programmatically create a Power BI dataset with data source connections;

1.Define your model with SQL Server as the source using the Microsoft.AnalysisServices.Tabular library.

2.Connect to the Power BI workspace using the XMLA endpoint and deploy the dataset.

3.Use the Power BI Admin REST API to set data source credentials after deployment (XMLA doesn't support credential input).

4. Make sure you authenticate with a gateway or service principal to securely manage credentials.

Please continue using Microsoft community forum.

If you found this post helpful, please consider marking it as "Accept as Solution" and give it a 'Kudos'. if it was helpful. help other members find it more easily.

Regards,
Pavan.

lbendlin
Super User
Super User

Push Datasets are an entirely different thing.

 

The usual approach is to prepare a template style PBIX, then upload that to the service and then change its data sources.

Imports - Post Import In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Datasets - Update Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Push dataset are where you push rows into tables via the API for a realtime solution. 

 

You could also look at using the pbip format and send to service with the fabric APIs


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.