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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
GerwinG
New Member

PowerBI Embedded Sample Connection string

I've been testing with the PowerBI Embedded sample files.

https://azure.microsoft.com/nl-nl/documentation/articles/power-bi-embedded-get-started-sample/

 

Everything is working fine except a direct query report. 

 

There is:

Option 7: update connection string info for an existing dataset

 

Does anyone know what we need too fill in there?

Connection is too a SQL server with 1 DB

 

 

19 REPLIES 19
zemag
Regular Visitor

I am also getting the same error message: "Bad Request" (see stack trace below) and I'm not really sure why.

 

After adding the new dataset (pbix file) I then execute #7, enter Username and Password (I'm assuming this is the same username and password used to connect to, in my case, the Azure SQL Database) and then enter the connection string with the server and database.  I entered the connection string in two different ways to no avail:

 

Data Source=xxxx.database.windows.net;Initial Catalog=dbName;User ID=xxx;Password=xxx;

 

and also:

 

Data Source=xxxx.database.windows.net;Initial Catalog=dbName;

 

I also deleted the published dataset and imported it again, but nothing.

 

Is there an updated version of the ProvisionSample code???

 

Ooops, something broke: Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'BadRequest'
at Microsoft.PowerBI.Api.V1.Datasets.<SetAllConnectionsWithHttpMessagesAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerBI.Api.V1.DatasetsExtensions.<SetAllConnectionsAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ProvisionSample.Program.<UpdateConnection>d__27.MoveNext() in C:\Users\EduardoGamez_vheyphg\Documents\Visual Studio 2015\Projects\PowerBI Embedded\ProvisionSample\Program.cs:line 592
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ProvisionSample.Program.<Run>d__17.MoveNext() in C:\Users\EduardoGamez_vheyphg\Documents\Visual Studio 2015\Projects\PowerBI Embedded\ProvisionSample\Program.cs:line 235

zemag
Regular Visitor

I figured it out! It appears that Power BI Embedded doesn't like it when you regular PBI data sets (I.e. Import type of connection not direct query) and direct query data sets. I removed this other data set from the workspace and imported my direct query data set. I then added the connection string by first specifying the username and password and then providing the connection string with the Data Source and Initial Catalog only. I did not get an error message but a confirmation that it was accepted. I went to my web app and I was able to access the embedded dashboard as expected. I hope this helps!

Power BI team - if you can please update the sample code with this important fact?

Thanks!
AnuragR
Regular Visitor

Hello I have been facing the same issue . Please share if it was resolved.
The Provision Sample was working fine but two days back it threw this exception exception and continues to do so , with the same connection string :

"data source=XXXX.database.windows.net;initial catalog=XXXX;"

 

Hi,

 

i have a similar issue..

can you please provide an udpate? 

 

I am trying to connect my power BI to > AWS windows machine as a gateway > this connects to AWS RDS to allow data refreshes....

 

I have set up an ODBC on AWS Windows machine and configured it....but when trying to link my POWER BI Gateway to my AWS machine it does not let me add data source

dyrcm
Frequent Visitor

Did you ever figure out how to solve the problem?  I am doing the same thing with the same result.

I updated the credentials and got a message "Connection information updated successfully".

But when i open the web app it says "Can't display the visual'.

 

Do I need to make changes to the EmbedSample code?

 

vth
Regular Visitor

I have solved the problem by adding the credentials (bold) to EmbedSample > Web.config:

 

<appSettings>
<add key="powerbi:AccessKey" value="X==" />
<add key="powerbi:Username" value="X" />
<add key="powerbi:Password" value="X" />
<add key="powerbi:ApiUrl" value="https://api.powerbi.com" />
<add key="powerbi:WorkspaceCollection" value="X" />
<add key="powerbi:WorkspaceId" value="Xcc" />
</appSettings>

 

and to EmbedSample > DashboardController.cs:

 

public class DashboardController : Controller
{
private readonly string workspaceCollection;
private readonly string username;
private readonly string password;
private readonly string workspaceId;
private readonly string accessKey;
private readonly string apiUrl;

public DashboardController()
{
this.workspaceCollection = ConfigurationManager.AppSettings["powerbi:WorkspaceCollection"];
this.username = ConfigurationManager.AppSettings["powerbi:Username"];
this.password = ConfigurationManager.AppSettings["powerbi:Password"];
this.workspaceId = ConfigurationManager.AppSettings["powerbi:WorkspaceId"];
this.accessKey = ConfigurationManager.AppSettings["powerbi:AccessKey"];
this.apiUrl = ConfigurationManager.AppSettings["powerbi:ApiUrl"];
}

 

Although I have started to get "Debug Assert failed: Warning: Feature switches have not been registered yet so switch values may not be correct". It seems it has something to do with the PowerBI update in March.

More about this issue:

http://community.powerbi.com/t5/Developer/Debug-Assert-failed-Feature-switches-have-not-been-registe...

http://community.powerbi.com/t5/Issues/Error-Feature-switches-have-not-been-registered-yet-so-switch...

Nithya
Frequent Visitor

Hi,

if you give connection string like below it will work 

 

Data Source=xxxx.database.windows.net;Initial Catalog=dbName;User ID=xxx;Password=xxx;

I have updated Connection string in the same format, then option 7 giving username and password for Azure SQL it says not data source found, please suggest me, Thanks.

I have updated Connection string in the same format, then option 7 giving username and password for Azure SQL it says not data source found, please suggest me, Thanks.

Thanks Nithya, your solution worked in my case!

 

P.S. This stuff is not easy or intuitive... I hope this Power BI embedded maintenance stuff will be enhanced. Why it is not possible to upload power bi report directly through Azure management portal?

I tried using same format but still getting following error - 

 

Ooops, something broke: Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'BadRequest'
at Microsoft.PowerBI.Api.V1.Datasets.<SetAllConnectionsWithHttpMessagesAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerBI.Api.V1.DatasetsExtensions.<SetAllConnectionsAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ProvisionSample.Program.<UpdateConnection>d__27.MoveNext() in C:\Projects\PowerBi\sample\Project\ProvisionSample\Program.cs:line 592
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ProvisionSample.Program.<Run>d__17.MoveNext() in C:\Projects\PowerBi\sample\Project\ProvisionSample\Program.cs:line 235

Please use a "Direct query" option (not import) when you are building the .pbix file. Once you do this deploy using option 6 then use the option 7 to update the connection string.

 

use the connection string in below format

 

"Data Source=xxxx.database.windows.net;Initial Catalog=dbName;User ID=xxx;Password=xxx;"

 

Note : this will work only for Sql server (not sure for other servers)

 

Regards

Sai 

I have updated Connection string in the same format, then option 7 giving username and password for Azure SQL it says not data source found, please suggest me, Thanks.

Did you get the issue resolved?
I am stuck at same place with same exception

Please share a solution

Thanks

Please use a "Direct query" option (not import) when you are building the .pbix file. Once you do this deploy using option 6 then use the option 7 to update the connection string.

 

use the connection string in below format

 

"Data Source=xxxx.database.windows.net;Initial Catalog=dbName;User ID=xxx;Password=xxx;"

 

Note : this will work only for Sql server (not sure for other servers)

 

Regards

Sai 

 

Finally made it to work after the following instruction from below link.

http://stackoverflow.com/questions/37919757/power-bi-embedded-change-connection-string-for-direct-qu...

gjross
New Member

Did you manage to resolve this? I am struggling to get a format for the connection sring that works to a SQL DB in Azure.

I have had the same issue though just fixing User Id and password was enough for my case.  You may want to just switch database pointing in local PowerBI Desktop and just update the credentials from Sample - Option 7-Gateway update.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors