Forum Discussion
PowerBI Embedded problem with Direct Query on Azure SQL
- 10 years ago
Direct Query is supported for the Embeded and you would need to configure the datasource after the import, here is how: https://msdn.microsoft.com/library/mt711498.aspx
https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-get-started/
Hope this helps,
Irina
Thanks a lot for your reply.
When it calls GetGatewayDatasourcesAsync(), it returns no data sources, so I receive no gateway id or data source id. Is it because the report is in direct-query mode? Or am I missing something?
I've embedded a few direct-query reports and they all have the same issue. The same report works fine in PowerBI Desktop and fine when I publish it to the web.
Here is a partial output of the Get Imports on my workspace. It shows a dataset, but no datasource or gateway ids.
,
This is the javascript I use to show the report:
<div id="reportContainer2" style="width: 100%; height: 330px;"></div>
...
var embedConfiguration1 = {
type: 'report',
accessToken: 'eyJ0e...3Q',
id: 'e5098782-dec3-473d-b740-2499becc4a61',
embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed',
settings: { filterPaneEnabled: false, navContentPaneEnabled: false },
filters: {
$schema: "http://powerbi.com/product/schema#basic",
"target": {
"table": "Circuits",
"column": "id_circuit"
},
"operator": "In",
"values": [257795,256022,256023]
}
};
var $reportContainer = $('#reportContainer1');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration1);
Note that the filter does not work at all so far, be it with a direct-query or imported report.
Here is the code I have used successfully.
static void UpdateAzureSqlDataSource(string workspaceCollectionName, string workspaceId, string datasetId) {
using (var client = CreatePowerBIClient()) {
IList<Dataset> datasets = client.Datasets.GetDatasetsAsync(workspaceCollectionName, workspaceId).Result.Value;
foreach (Dataset dataset in datasets) {
if (dataset.Name == datasetId) {
var datasources = client.Datasets.GetGatewayDatasourcesAsync(workspaceCollectionName, workspaceId, dataset.Id).Result;
// Reset your connection credentials
var delta = new GatewayDatasource {
CredentialType = "Basic",
BasicCredentials = new BasicCredentials {
Username = azureSqlUser,
Password = azureSqlPassword
}
};
// Update the datasource with the specified credentials
client.Gateways.PatchDatasourceAsync(workspaceCollectionName,
workspaceId,
datasources.Value[0].GatewayId,
datasources.Value[0].Id,
delta).Wait();
}
}
}
}
Here is the flow when you already know the datset name dataset:
- Call client.Datasets.GetDatasetsAsync and get all datsets in workspace
- Enumerate through datsets and find dataset and dataset ID of dataset with matching name
- Call client.Datasets.GetGatewayDatasourcesAsync and pass dataset ID to get datasource ID you need to update
- Call to GetGatewayDatasourcesAsync to get datasource
- Note that datasource is accessible through datasources.Value[0].
- The datasources.Value[0] object has an ID property for datasource ID
- The datasources.Value[0] object has an GatewayID property for gateway ID
- Create GatewayDatasource object to servie as input parameter with credentials
- Pass GatewayDatasource object in call to client.Gateways.PatchDatasourceAsync
- ccounotte9 years agoFrequent Visitor
Thanks a lot for your time and suggestions.
At this point, the call to client.Datasets.GetGatewayDatasourcesAsync(workspaceCollectionName, workspaceId, datasetId); always returns a datasources with Value.Count = 0, on any dataset IDs I've already embedded.
So I can't retrieve get any required ID to call the patch datasource REST API.
I tried to locate those IDs in 'manage gateways' on the web, no ID are reported there. Tried in PowerBI Desktop, same thing, no ID reported.
- sherylmeg9 years agoFrequent Visitor
I'm having a similar problem that started once I moved my SQL Server to an Azure VM from SQL Azure. When my database was hosted on SQL Azure I was able to upload a pbix that uses direct query and update the connection settings. I have since started using a SQL DB on an Azure VM as the data source and am unable to update the connection settings. When running client.Datasets.GetGatewayDatasourcesAsync(workspaceCollectionName, workspaceId, datasetId) the datasets always return datasources with Value.Count = 0.
This post seems to discuss the problem and mentions that there might be a solution soon.
https://github.com/Microsoft/PowerBI-Cli/issues/29
"wbreza commented on Aug 18, 2016
After following up with julianmbs offline the scenario ended up being a SQL DB on an Azure VM and not pure SQL Azure. This scenario is technically treated the same as "on-premise" support which will be supported sometime in Fall 2016."Any news regarding this?
Thanks
- ccounotte9 years agoFrequent Visitor
Wished I knew about this issue before I wasted so many days trying to make it work. We actually dropped PBI because of that.