diff --git a/api/GetEmbedInfo/embedConfigService.js b/api/GetEmbedInfo/embedConfigService.js index 87a6f681c..e8bbc0108 100644 --- a/api/GetEmbedInfo/embedConfigService.js +++ b/api/GetEmbedInfo/embedConfigService.js @@ -11,11 +11,12 @@ const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fet * Generate embed token and embed urls for reports * @return Details like Embed URL, Access token and Expiry */ -async function getEmbedInfo(reportsIds) { +async function getEmbedInfo(reportsIds, workspaceId) { // Get the Report Embed details try { // Get report details and embed token - const embedParams = await getEmbedParamsForSelectedReports(process.env.POWER_BI_WORKSPACE_ID, reportsIds); + const workspacePBIId = workspaceId ?? process.env.POWER_BI_WORKSPACE_ID; + const embedParams = await getEmbedParamsForSelectedReports(workspacePBIId, reportsIds); return { accesses: { accessToken: embedParams.embedToken.token, diff --git a/api/GetEmbedInfo/index.js b/api/GetEmbedInfo/index.js index 366871f2a..aabf49b02 100644 --- a/api/GetEmbedInfo/index.js +++ b/api/GetEmbedInfo/index.js @@ -39,7 +39,8 @@ module.exports = async function (context, req) { }; } else { const reportsIds = req?.body?.reports; - const result = await embedToken.getEmbedInfo(reportsIds); + const workspaceId = req?.body?.workspaceId; + const result = await embedToken.getEmbedInfo(reportsIds, workspaceId); context.res = { status: 200, body: result }; } } diff --git a/api/GetEmbedInfo/utils.js b/api/GetEmbedInfo/utils.js index 1f30263c5..b19e0f1f3 100644 --- a/api/GetEmbedInfo/utils.js +++ b/api/GetEmbedInfo/utils.js @@ -27,17 +27,6 @@ function validateConfig() { ); } - if (!process.env.POWER_BI_WORKSPACE_ID) { - return 'WorkspaceId is empty. Please select a group you own and fill its Id in the environment variables.'; - } - - if (!guid.isGuid(process.env.POWER_BI_WORKSPACE_ID)) { - return ( - 'WorkspaceId must be a Guid object. Please select a workspace you own and fill its Id in the environment ' + - 'variables.' - ); - } - if (!process.env.POWER_BI_CLIENT_SECRET || !process.env.POWER_BI_CLIENT_SECRET.trim()) { return 'ClientSecret is empty. Please fill Power BI ServicePrincipal ClientSecret in the environment variables.'; } diff --git a/doc/powerBI.md b/doc/powerBI.md index 6f525582e..e511c9fe5 100644 --- a/doc/powerBI.md +++ b/doc/powerBI.md @@ -632,15 +632,11 @@ below: | ------------------------ | ------------------------------------------------------------------------------------- | | `POWER_BI_SCOPE` | "https://analysis.windows.net/powerbi/api/.default" | | `POWER_BI_CLIENT_ID` | client id of the webapp app registration (visible in the _Overview_ blade) | -| `POWER_BI_WORKSPACE_ID` | id of the Power BI workspace containing your reports | | `POWER_BI_AUTHORITY_URI` | "https://login.microsoftonline.com/common/v2.0" | | `POWER_BI_CLIENT_SECRET` | a client secret generated in your app registration for PowerBI | | `POWER_BI_TENANT_ID` | tenant id of your app registration (visible in the _Overview_ blade) | | `CSM_API_TOKEN_AUDIENCE` | (optional) if defined, queries whose token don't match this audience will be rejected | -The value for `POWER_BI_WORKSPACE_ID` can be found in the PowerBI service URL: when your report is opened, the workspace -id is visible after `/groups/` in the URL (e.g. "https://app.powerbi.com/groups/YOUR_WORKSPACE_ID/"). - For `POWER_BI_CLIENT_SECRET`, you can create a new client secret from _Azure Portal_ > _App Registrations_ > _[name of your webapp app registration]_ > _Certificates & secrets_. @@ -661,7 +657,6 @@ JSON file. Create a _**local.settings.json**_ file in the **api** folder with th "Values": { "POWER_BI_SCOPE": "https://analysis.windows.net/powerbi/api/.default", "POWER_BI_CLIENT_ID": "INSERT CLIENT ID HERE", - "POWER_BI_WORKSPACE_ID": "INSERT POWER BI WORKSPACE ID HERE", "POWER_BI_AUTHORITY_URI": "https://login.microsoftonline.com/common/v2.0", "POWER_BI_CLIENT_SECRET": "INSERT CLIENT SECRET HERE", "POWER_BI_TENANT_ID": "INSERT TENANT ID HERE", diff --git a/src/services/powerbi/PowerBIService.js b/src/services/powerbi/PowerBIService.js index 5c08b7aa6..3afa4f936 100644 --- a/src/services/powerbi/PowerBIService.js +++ b/src/services/powerbi/PowerBIService.js @@ -54,7 +54,7 @@ const getPowerBIDataWithServiceAccount = async (powerBIWorkspaceId, reportsIds) const { headers } = await getAuthenticationInfo(COSMOTECH_API_SCOPE); const { data } = await clientApi.post( GET_EMBED_INFO_URL, - { reports: reportsIds }, + { reports: reportsIds, workspaceId: powerBIWorkspaceId }, { headers: { 'csm-authorization': headers.Authorization } } ); return {