Sub topic 3
When a dataset needs an on-premises data gateway
This chapter assumes you can build a report in Power BI Desktop with Power Query. It also assumes you know what a workspace is and have basic Windows networking knowledge, such as firewalls and outbound ports. The previous chapters covered storage modes and scheduled refresh. Here you decide whether a published dataset needs a gateway.
The rule
A gateway is a Windows service you install inside your network. It lets the Power BI service reach data sources that the cloud cannot reach directly. The rule has two parts:
- Does the service need to contact the data source at refresh time or query time? Import mode needs this during refresh. DirectQuery and live connections need it on every user interaction.
- Can the service reach the source over the public internet? If not, you need a gateway.
A dataset that was fully imported and is never refreshed does not need a gateway. It holds a snapshot, so the service never contacts the source.
Which sources need a gateway
| Data source | Gateway needed? | Reason |
|---|---|---|
| SQL Server on a corporate network | Yes | The server is not reachable from the internet |
| SQL Server on an Azure VM in a private virtual network | Yes | The server has no public endpoint |
| Excel or CSV file on a local drive or file share | Yes | The service cannot read local or network paths |
| Azure SQL Database with public access | No | The service connects directly |
| SharePoint Online or OneDrive for Business file | No | It is a cloud source |
| Analysis Services on-premises (live connection) | Yes | Queries are sent through the gateway |
How the decision plays out by storage mode
- Import with on-premises sources: the gateway is used only while a refresh runs, whether scheduled or on demand.
- DirectQuery with on-premises sources: the gateway is used for every query. There is no refresh to schedule for the data, but the gateway must be available all the time.
- Live connection to on-premises Analysis Services: the same as DirectQuery. Queries go through the gateway.
A dataset can need a gateway for only one of its sources
A dataset often combines sources. If one query reads an on-premises SQL Server and another reads a SharePoint Online list, the dataset needs a gateway. Every on-premises source in the dataset must be defined on a gateway. Cloud sources in the same dataset do not need to be.
Consider this query. The server sql01.contoso.local is a private name, so the service cannot resolve it.
let
Source = Sql.Database("sql01.contoso.local", "Sales"),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data]
in
OrdersIf you publish a dataset with this query and schedule a refresh without a gateway, the refresh fails. The service cannot reach the server, and the dataset settings page shows that a gateway is needed.
Common mistakes
- Assuming a refresh works because it works in Power BI Desktop. Desktop runs on your machine, which is inside the network. The service is not.
- Forgetting a source that is hidden in a query. A lookup file on a file share is enough to require a gateway.
- Using a gateway when the source is already public. A gateway adds an extra point of failure.
Exercise
A dataset imports one table from a SQL Server on your office network and one list from SharePoint Online. It refreshes daily. Does it need a gateway, and for which source?
Show answer
Yes. It needs a gateway for the SQL Server source, which is on a private network. The SharePoint Online list is a cloud source and does not need one.
Exercise
A report uses DirectQuery against an on-premises SQL Server. A colleague says no gateway is needed because no refresh is scheduled. Is that correct?
Show answer
No. DirectQuery sends a query to the source on every interaction, so the service must reach the server through a gateway even though there is no data refresh to schedule.