Power BI Embedded: Step 2 - Create a workspace with Node.js and add a report

Using Power BI Embedded you can integrate your report in a website or web-application. To do so there are three parts you need to do:

  • Configure your Azure environment
  • Add a Power BI workspace to this environment and upload a report
  • Implement the code to generate a token and embed your report

In this post we will zoom in on the second part. In the previous post we’ve created a Power BI Workspace Collection in Azure. We will use the Access Key of this collection to add a workspace and upload our .PBIX Power BI report.

Starting July '17 Power BI Embedded will be part of the new Power BI Premium service. The current setup explained in this post will be supported for a limited amount of time. If the way of working changes, this post will be updated.

Create a workspace using Node.js

Uploading a report to Azure is done using a workspace. Adding a workspace is – at the moment – only possible using a Command Line Interface (CLI). In this example we use the Command Line Interface written for Node.js. If you don’t like using Node.js you can also have a look at ASP.NET example on the Microsoft website.

  1. We start by downloading Node.JS and NPM via https://nodejs.org/en/
  2. Install Node.js with default settings
  3. Open the Node.js Command Prompt (not the Node.js desktop application)
  4. Install the Power BI command line interface using the commando: npm install powerbi-cli -g

To create a new workspace we use the command:

powerbi create-workspace -c <collection> -k <accessKey>
  • <collection>: Fill in your Azure Workspace Collection
  • <accessKey> : Fill in your Azure Workspace Collection Access Key

To see if your workspace is correctly added to the Workspace Collection use the command:

powerbi get-workspaces

A second check is to go back to your Azure Power BI Workspace Collection resource. In the Summary field of the resource we should see a new workspace.


Upload a report to this workspace
Using the same tool we can also upload a report to the workspace. Use the command:

powerbi import -c <collection> -w <workspaceId> -k <accessKey> -f <file> -n [name] -o [overwrite]
  • <collection>: Fill in your Azure Workspace Collection
  • <accessKey> : Fill in your Azure Workspace Collection Access Key
  • <file>: Fill in the complete file path, for example:
  • C:\Users\john.doe\Documents\Project\ MyExampleReport.pbix
  • <name>: Pick a name for this report
  • -o : fill in [overwrite] if you would like to overwrite a previous upload

To check if your upload is successful, use the command:

powerbi get-datasets

In the next post we will generate a token using PHP. To do so we need the workspace ID and the report ID. Use the following command to retrieve that information:

powerbi get-workspaces

powerbi get-datasets

Lars Bouwens is Business Intelligence consultant at Motion10 and likes to read and write about Power BI and Azure.

Leave a Reply

Next ArticlePower BI Embedded: Step 3 - integrate your report using PHP and JavaScript