Sub topic 8
Setting data source credentials and gateways
This chapter assumes you can build a report in Power BI Desktop, you have published one to a workspace, and you know that publishing creates both a report and a semantic model. Credentials belong to the semantic model, so that is where you set them.
Why credentials are not published
Power BI Desktop stores your sign-in details on your own computer. When you publish, the .pbix file goes to the service but your saved credentials do not. The service has to be told how to reach each data source again.
This is the most common reason a published report shows data once and then fails to refresh. The report opens, the visuals show the cached data, and the first scheduled refresh fails with a credentials error.
Where to set credentials
- Open the workspace and find the semantic model.
- Select the ... menu next to it, then Settings.
- Expand Data source credentials.
- Select Edit credentials next to each source that shows an error.
- Choose an authentication method, set the privacy level, and select Sign in or Save.
Common authentication methods:
| Method | Typical use | Watch for |
|---|---|---|
| Basic | SQL Server or other databases with a username and password | The password is stored by the service. Update it when it changes. |
| OAuth2 | Azure SQL, SharePoint Online, many cloud services | The token is tied to the account that signed in. If that account is disabled or its password resets, refresh fails. |
| Anonymous | Public web pages and open files | Only for data that needs no sign-in. |
| Windows | On-premises sources through a gateway | Needs a gateway data source. |
Use a service account where you can, not a personal account. A refresh that depends on one person's sign-in breaks when that person leaves or changes their password.
Privacy levels
Each source also has a privacy level: Private, Organizational, or Public. When a query combines two sources, the privacy level controls whether data may be sent from one source to the other. Setting every source to Public to silence a warning can expose private data to another source, so choose the level that matches the data.
When you need a gateway
A gateway is software that runs on a machine inside your network. It lets the Power BI service reach data that is not reachable from the internet. Without one, the service cannot connect to on-premises sources.
You need a gateway when the semantic model uses:
- A SQL Server or file share on your internal network.
- A source behind a firewall or private network.
- Any on-premises source in Import mode that you want to refresh on a schedule.
You do not need one for cloud sources that are reachable from the internet, such as SharePoint Online or a public Azure SQL endpoint.
Connecting the model to a gateway
- Install an on-premises data gateway on a machine that stays on and can reach the data source. Sign in with your work account and register it.
- In the Power BI service, open Settings, then Manage connections and gateways.
- Add a connection to your gateway. Enter the server and database names, the authentication method, and the credentials.
- Open the semantic model settings and expand Gateway and cloud connections.
- Map each data source in the model to a gateway connection, then select Apply.
The server and database names must match the ones in the .pbix file exactly. A different spelling or an alias is a different data source, and the mapping will not appear.
A standard gateway is shared by many people. A personal-mode gateway serves only one user and is a poor fit for shared reports, so avoid it for production.
Common errors
- Credentials are not valid or have expired. Edit the credentials and sign in again. For OAuth2 sources, this is often an expired token.
- The semantic model has no gateway mapping. The source is on-premises and no connection is mapped. Complete the gateway steps above.
- The gateway is offline. The machine is off, the gateway service has stopped, or it cannot reach the internet. Check the service on the gateway machine.
- Data source mismatch. The server name in the model differs from the one in the gateway connection.
Fix credentials before you set up a schedule. Chapter on scheduled refresh builds on this, and a refresh configured on a model with broken credentials simply fails.
Exercise
A colleague publishes a report that reads from a SQL Server in your office network. The report opens with data, but the scheduled refresh fails the next morning. Name two things to check in the semantic model settings.
Show answer
First, check that the semantic model is mapped to a gateway connection under Gateway and cloud connections, since the service cannot reach an on-premises SQL Server without one. Second, check that the credentials for that source are saved and valid, and that the server and database names match the gateway connection exactly. You can also confirm the gateway machine is online.