I have a Report.pbix file which connects to Azure SQL using DirectQuery. All the tables in this PBIX connect as follows:
let Source = Sql.Database("mycustomer1.database.windows.net", "reportdb"),...
I am able to import this exact PBIX to all of my customers workspaces and have used powerbi update-connection (Post SetAllConnections) to set the correct datasource for each customer#:
{ connectionString: 'data source=[mycustomer#].database.windows.net;initial catalog=reportdb;persist security info=True;encrypt=True;trustservercertificate=False' }
In other words, the PBIX is set to a single customer's Azure SQL hostname and I use SetAllConnections to specify a different Azure SQL hostname for each workspace/dataset that I upload this PBIX to. I also set the correct dataset credentials right after each PBIX is uploaded.
However, the embed only works for the customer whose SQL server was originally hardcoded into the PBIX file. For everyone else, I get "See details" and the XHR JSON for querydata shows:
...{"Id":"DS0","odata.error":{"code":"QuerySystemError","source":"PowerBI","message":{"lang":"en-US","value":"Failed to execute the DAX query."}...
Instead of hardcoding the Azure hostname, I also tried using a query parameter and I get the same results.
1) Is there a way to change the query parameter (which contains the SQL server hostname) either during import PBIX via command-line or when embedding it on to a webpage?
2) It is even possible to change the SQL server hostname used by all the tables in a PBIX file via REST API (i.e. without using PowerBI Desktop)?
3) If I have 100 customers and each of them needs the exact same PBIX but pointing to their own SQL server, do I need 100 copies of the PBIX file with the query parameter set to each customer's SQL server? This seems insane to maintain but after hours of searching online, I'm beginning to feel there is no alternative.
Note: We need to keep each customer's data on separate SQL server (not just separate DB) for regulatory/legal reasons.
Thanks for your assistance in advance.