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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rshahrabani
Frequent Visitor

Set datasource credentials programmatically

We are building an ISV application that uses Power BI embedding for rendering of Power BI reports.  This application will be distributed to client sites and each will have different database logins (username/password) for all their reports.

 

We need a way to programmatically (and securely) set these datasource credentials at runtime when a user attempts to run the report.  These credentials cannot be appended as parameters to the URL or other insecure methods.

 

Does anyone have a method for doing this dynamically in C#?  Your help is much appreciated.

Ronny

1 ACCEPTED SOLUTION

Hi @rshahrabani,

Maybe you can try to parameterize your connection string based on query parameters, then you can dynamically switch Datasource(same data structure) based on posted query parameters and Datasource credentials.

Using the Power BI Service Parameters to change connection strings (To possibly change between Dev  

power bi embedded, change connection string for direct query 

Power BI Embedded Query Parameters API 

In addition, you can also take a look at the following link to switch between different contents:

Tutorial: Embed Power BI content into an application for your customers 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @rshahrabani,

I'd like to suggest you take a look at gateway update data source api and try to use it to set data source credentials.

Gateways - Update Datasource 

BTW, I don't think it is possible to update credentials every time when the user accesses. Maybe you can try to set dynamic RLS based on username and configure them in user data.

Row-level security with Power BI Embedded 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft,

 

The Gateways - Update Datasource will modify the credentials on the report residing in the Power BI service, and Row-level security will limit the data to a subset given the username. What we are trying to do is to allow execution of a report's datasource login to be configured for different users.

 

For example, a client site will have 3 databases (development, QA and production) with identical structures (but different data).  The development site will execute the report residing on Power BI service with one set of database credentials (username/password) and the QA site will execute the same report on Power BI service with a different set of credentials. This database login needs to be established at runtime with different credentials for each of these platforms (dev, QA and prod).

 

Is there any way to do this programmatically within our Power BI embedded app?

 

Thanks,

Ronny

Hi @rshahrabani,

Maybe you can try to parameterize your connection string based on query parameters, then you can dynamically switch Datasource(same data structure) based on posted query parameters and Datasource credentials.

Using the Power BI Service Parameters to change connection strings (To possibly change between Dev  

power bi embedded, change connection string for direct query 

Power BI Embedded Query Parameters API 

In addition, you can also take a look at the following link to switch between different contents:

Tutorial: Embed Power BI content into an application for your customers 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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