Sub topic 3
Setting Data Source Credentials and Gateways
Assume you can build a report in Power BI Desktop and can sign in to the Power BI service. A semantic model is the data behind a report. After publishing, the service needs permission to connect to that data.
Set credentials and a gateway
Open the workspace, then open the semantic model's settings. Under Data source credentials, choose the authentication method and enter the account details. The method must match the source, such as OAuth for some cloud services or basic authentication for supported sources.
If the source is inside a private network, such as an on-premises SQL Server, install and configure an on-premises data gateway. A gateway is software that securely connects the Power BI service to a private data source. Add the data source to the gateway, then map the semantic model to it.
| Data source location | Typical requirement |
|---|---|
| Cloud database | Data source credentials |
| On-premises database | Credentials and an online gateway |
| File on a local computer | Move it to supported cloud storage or use a gateway |
Configure scheduled refresh
In the semantic model settings, open Scheduled refresh. Turn it on, select the time zone, and choose the refresh frequency allowed by your license or capacity. Save the schedule and run Refresh now once.
A refresh can fail when credentials expire, the gateway is offline, the source schema changed, or the account cannot read the data. Check Refresh history for the error details.
Check and share the report
Open the published report from the workspace. Test filters, visuals, drill-through pages, and dates. Compare a few values with Power BI Desktop. Confirm that the semantic model refreshed successfully.
Share the report only with the intended users or groups. Use workspace roles when users need to collaborate. Otherwise, use report sharing or an app for read-only distribution. Licensing and capacity determine whether recipients can view the content.
Publish from a script
PowerShell can upload a .pbix file to a workspace:
Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser
Connect-PowerBIServiceAccount
$ws = Get-PowerBIWorkspace -Name 'Sales Analytics'
New-PowerBIReport -Path '.\Sales.pbix' -Name 'Sales' -Workspace $ws -ConflictAction CreateOrOverwriteThe REST API provides the same operation for automation. Supply an access token, workspace ID, and file:
curl -X POST "https://api.powerbi.com/v1.0/myorg/groups/$GROUP_ID/imports?datasetDisplayName=Sales&nameConflict=CreateOrOverwrite" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-F "[email protected]"Exercise
A published report cannot refresh from an on-premises database. What should you check first?
Show answer
Check that the gateway is online, the source is registered on it, the semantic model is mapped to that source, and its credentials are valid.