A simple script for creating Power BI Embedded Workspaces and uploading reports in one command. It uses Python to combine two command lines tools to achieve creating a workspace collection, creating a workspace, uploading the report, and setting the credentials on the report.
You have two options:
The python script above assumes you have already installed the following and they are on your path. Skip to docker usage if you don't want to install everything.
After those tools are installed you can run it with the following:
python createworkspacecollection.py -s <azure-subscription-id> -r <azure-resource-group> -w <workspace-collection-name> -l <azure-location> -f <path-to-pbix-file> -n <datasource-name> -u <datasource-username> -p <datasource-password>
You can either pull this repository and build the docker image locally or you can grab a image from my Docker Hub repository.
Navigate to the location of the PowerBi Embedded .pbix
file and run the following. This created a volume in docker and links the current directory up in the Docker Container allowing the script to see the .pbix
file (below works on windows; Change %CD%
to $(pwd)
on a mac/linux).
docker run -it --rm -v %CD%:/usr/src/ jsturtevant/power-bi-embedded-workspace-script python createworkspacecollection.py -s <azure-subscription-id> -r <azure-resource-group> -w <workspace-collection-name> -l <azure-location> -f <path-to-pbix-file> -n <datasource-name> -u <datasource-username> -p <datasource-password>
- As of writing there is a bug in PowerBI Embedded CLI on macs and linux. The fix-pbcli-linux shows how to fix on linux and the issue tells you how to fix on mac.
- Your workspace collection name must be unique across all workspace collection names in Azure.
- The script currently only uploads one file but could easily be tweaked to upload all reports in a folder.