The Power BI Management cmdlets (see the announcement on this blog) are now available in Azure Cloud Shell. This is great news—especially for those of you who want to get started quickly without installing additional PowerShell modules locally. It is also a viable workaround if you are struggling with errors due to PowerShell configuration issues on your local workstation. If you encounter an error due to version mismatches or assembly conflicts, such as “Could not autoload matching module” or “Could not load file or assembly”, why not head over to Azure Cloud Shell and get your work done without this friction? Every Power BI tenant is backed by an Azure AD instance. So, if you can log in to Power BI, you can log in to Azure Cloud Shell by using the same user account.
Azure Cloud Shell offers an interactive, browser-accessible PowerShell environment running on Linux—and thanks to full support for .NET Core, you can use the Power BI cmdlets in this environment! For a good overview, see the article Overview of Azure Cloud Shell. Not only can you avoid frustrating assembly conflicts, but you can run your commands directly in the Azure data center where your Power BI tenant is hosted. This guarantees the best network performance.
To launch Azure Cloud Shell, go to https://shell.azure.com/ and sign in with your user account. You can also launch Azure Cloud Shell from the Azure Portal by clicking on the shell button in the upper toolbar. Azure Cloud Shell might prompt you to choose between Bash and PowerShell. Make sure you click on “PowerShell (Linux)”, as in the following screenshot.
If necessary, Azure Cloud Shell will also prompt you for an Azure subscription and a storage account. This is the only caveat. Azure Cloud Shell requires a subscription and a storage account, which carry a moderate price tag. The Azure Pricing Calculator can help to determine actual costs. Moreover, extended trial and pay-as-you-go options are available, but if you cannot or do not want to provision these resources, then Azure Cloud Shell won’t work. In this case, you must update the .NET Framework and PowerShell on your workstation and uninstall any modules that might conflict with the Power BI cmdlets to get unblocked. Refer to the section Supported Environments and PowerShell Versions in the Power BI cmdlets documentation.
Assuming Azure Cloud Shell is an option, you can use the Power BI cmdlets without having to install any additional modules. Just type Login-PowerBI and follow the instructions. Note that the application identifies itself as Power BI Gateway. This is confusing and needs some cleanup in the future, but for now this is what it’s called. Click “Continue” to complete the login process.
And that’s it! You can now use the Power BI cmdlets in the cloud as if you were running them on your local workstation. For example, as a Power BI administrator, use the Get-PowerBIWorkspace -Scope Organization command to enumerate all workspaces in your Power BI tenant, or use any of the other Power BI cmdlets to your heart’s content. Stay tuned for more blog posts covering Power BI cmdlet scenarios.