MICROSOFT POWER BI • CONNECTING TO DATA

Gateways — Understand gateway concepts for on-prem refresh (conceptual)

Bridge your on-premises data sources to the Power BI cloud service securely and reliably.

Historical Context & Motivation

The modern enterprise does not keep all its data in a single location. For decades, organizations have maintained relational databases, file servers, and data warehouses behind corporate firewalls — infrastructure collectively referred to as on-premises (on-prem) data sources. When cloud-based analytics platforms such as Microsoft Power BI appeared, a fundamental architectural question arose: how can a cloud service consume data that lives inside a private network without compromising security or requiring organizations to replicate entire databases into the cloud?

The answer is a data gateway — a software bridge that sits inside the corporate network, authenticates with the cloud service over an encrypted outbound connection, and relays query requests and data payloads. Understanding gateways is essential for any computer science student working with hybrid cloud architectures, because the pattern extends well beyond Power BI into Azure Data Factory, Logic Apps, and similar services.

2010
Rise of Self-Service BI
Microsoft releases Power Pivot for Excel, enabling analysts to import and model data locally. Data still resides on-prem or in personal files, with no cloud refresh requirement.
2015
Power BI Service Launches
Power BI moves to a SaaS model. Datasets published to the cloud can connect to cloud sources natively, but on-prem sources require a relay mechanism — the On-Premises Data Gateway is introduced.
2017
Personal vs. Standard Modes
Microsoft formalizes two gateway modes: a personal gateway (single user) and a standard/enterprise gateway (shared across an organization), reflecting enterprise governance needs.
2020
VNet Data Gateways
For resources already in Azure, Microsoft introduces Virtual Network (VNet) data gateways, eliminating the need for a local machine by running the gateway as a managed service within an Azure VNet.
2023
Fabric & Gateway Evolution
With the launch of Microsoft Fabric, gateway management is unified under the Fabric portal, and on-prem connectivity becomes a first-class pillar of the lakehouse architecture.

The central question this lesson addresses is conceptual: how does the gateway architecture securely bridge the divide between on-prem data and a cloud-hosted analytics service? We will examine the gateway's communication model, its deployment modes, the data-flow pipeline, and the security guarantees it provides.

Core Principles & Definitions

Before diving into architecture diagrams and deployment details, it is important to establish several foundational concepts that underpin the gateway model. These principles apply not only to Power BI but to any hybrid cloud integration pattern where a trusted agent must relay data across a trust boundary.

1

Outbound-Only Communication

The gateway initiates all connections outbound to Azure Service Bus over HTTPS (port 443). No inbound firewall ports need to be opened, preserving the corporate perimeter.
2

Encrypted Transit & At-Rest Keys

All data in transit is encrypted with TLS 1.2+. Credentials for on-prem data sources are encrypted with an asymmetric key pair whose private half never leaves the gateway machine.
3

Scheduled & On-Demand Refresh

Power BI datasets can trigger a scheduled refresh (e.g., every 30 minutes) or an on-demand refresh. Both rely on the gateway to execute queries against on-prem sources and push results to the cloud.
4

Gateway Cluster (High Availability)

Multiple gateway installations can be grouped into a cluster. The cloud service distributes requests across healthy cluster members, providing fault tolerance similar to a load-balanced service pool.
5

Data Source Registration

Each on-prem data source (e.g., a SQL Server instance) must be registered on the gateway with its connection string and credentials. This decouples report authors from infrastructure details.
KEY TAKEAWAY
Think of the on-premises data gateway like a reverse SSH tunnel that a sysadmin sets up from inside a private network to an external server. The gateway dials out to Azure Service Bus, holds open a persistent relay channel, and waits for instructions. Because all traffic originates from within the firewall, the corporate network never needs to expose an inbound port — exactly the same security posture as a reverse tunnel, but wrapped in a managed, enterprise-grade service.

Visual Explanation — Gateway Data-Flow Architecture

The following diagram illustrates the end-to-end data flow when a Power BI dataset configured for on-prem refresh triggers a scheduled refresh. Each numbered step shows the direction of communication and the protocol involved.

Step ① Power BI Service triggers a refresh and sends a query request to Azure Service Bus. Step ② The relay forwards the query to the gateway over the persistent outbound connection. Step ③ The gateway executes the query against the on-prem data source. Step ④ Results are returned through the relay to the Power BI Service. Credentials (bottom right) are stored in Azure Storage but encrypted with a key that only the gateway machine holds.

Notice that the dashed boundary on the left represents the corporate firewall. The gateway machine lives inside this boundary and reaches out to Azure Service Bus — never the other way around. This outbound-only communication model is the architectural linchpin that makes on-prem refresh feasible without altering firewall ingress rules. From a networking standpoint, the gateway behaves like a long-running WebSocket client that keeps a relay channel open, waiting for work items dispatched by the Power BI Service.

How the Gateway Works — Communication & Credential Management

Communication Protocol Stack

When the gateway Windows service starts, it performs an OAuth 2.0 authentication against Azure Active Directory (now Microsoft Entra ID) using the service account's credentials. Upon successful authentication, it receives a token and opens one or more Azure Relay hybrid connections — essentially WebSocket tunnels — to its assigned Service Bus namespace. The Power BI Service places query requests onto this relay, and the gateway pulls them off, executes the query locally, serializes the result set, and pushes it back through the same tunnel.

Credential Encryption Model

Security-sensitive credentials follow an asymmetric encryption model. During gateway installation, a 2048-bit RSA key pair is generated. The public key is uploaded to the Power BI Service and stored alongside the gateway registration record. When an administrator configures a data source and enters credentials through the Power BI portal, those credentials are encrypted with this public key in the browser before transmission. The ciphertext is stored in Azure, but only the gateway machine — which holds the corresponding private key in the local Windows Certificate Store — can decrypt it. This guarantees that Microsoft's cloud infrastructure never has access to plaintext database passwords.

CREDENTIAL ENCRYPTION
C = E(PUBgateway, plaintext_credentials)
Where C is the ciphertext stored in Azure, E is RSA-OAEP encryption, and PUBgateway is the public key generated during gateway installation. Decryption requires PRIVgateway, which never leaves the gateway machine.

Query Execution Pipeline

  1. Receive: The gateway pulls a query message from the Service Bus relay. The message contains metadata (dataset ID, data source reference) plus the M or SQL query text.
  2. Decrypt: The gateway decrypts the stored credentials using its private key, constructs a connection string, and opens a connection to the on-prem data source.
  3. Execute: The query runs against the data source (e.g., SQL Server). Results are serialized into a compressed binary format.
  4. Return: Compressed results are pushed back through the relay to the Power BI Service, which updates the dataset's cached model.
⚠️ Security Note
Because the private key is stored in the Windows Certificate Store on the gateway machine, losing or decommissioning the gateway machine without a recovery key backup makes all stored credentials irrecoverable. Administrators must re-enter all data source credentials if a gateway is migrated to a new host without the recovery key.

Gateway Modes & Deployment Classifications

Microsoft offers three distinct deployment modes for data gateways, each targeting a different operational profile. Choosing the right mode is an architectural decision that balances governance, cost, and complexity.

Three gateway modes compared side-by-side. The Standard (Enterprise) gateway supports clustering and DirectQuery and is the most common enterprise choice. Personal Mode is lightweight but restricted to a single user with import-only refresh. VNet Data Gateways eliminate on-prem hardware entirely when sources already reside in Azure.

The distinction between Import mode and DirectQuery mode is particularly important when choosing a gateway. In Import mode, the gateway executes bulk queries during a scheduled refresh and sends the full result set to the cloud, where it is stored as a compressed columnar model. In DirectQuery mode, each user interaction with a report generates a live query that the gateway must relay in real time — this imposes significantly higher throughput requirements on the gateway machine and the on-prem data source. Only the Standard gateway supports DirectQuery; the Personal gateway is limited to Import.

💡 When Do You NOT Need a Gateway?
If all of your data sources are cloud-native (e.g., Azure SQL Database, Snowflake, Google BigQuery, SharePoint Online), the Power BI Service can connect to them directly over the public internet or via private endpoints. A gateway is only required when data sources reside behind a firewall or inside a private network that the cloud service cannot reach directly.

Worked Example — Setting Up an On-Prem Refresh Pipeline

Consider a scenario in which Contoso Corporation's BI team needs to publish a sales dashboard to the Power BI Service. The dashboard pulls from a SQL Server 2019 instance running on a dedicated Windows Server inside Contoso's data center. Walk through the conceptual steps required to enable a daily scheduled refresh.

Enabling Scheduled Refresh for an On-Prem SQL Server
1
Step 1 — Install the Standard GatewayA gateway administrator downloads the on-premises data gateway installer from https://aka.ms/gateway and installs it on a Windows Server VM (GW-VM-01) that has network access to the SQL Server instance. During installation, the administrator signs in with an Azure AD / Entra ID organizational account and registers the gateway with the Power BI tenant. A 2048-bit RSA key pair is generated, and the public key is uploaded to the Power BI Service.
Gateway Contoso-GW-01 appears in the Power BI Admin Portal under Manage Gateways.
2
Step 2 — Add a Second Node for High AvailabilityOn a second server (GW-VM-02), the administrator installs the gateway and selects 'Add to an existing gateway cluster' during setup. The cloud service now distributes queries across both nodes using a round-robin or least-loaded strategy.
Cluster Contoso-GW-01 now shows two healthy members.
3
Step 3 — Register the Data SourceIn the Power BI portal, the admin navigates to the gateway settings and adds a new data source of type 'SQL Server'. They enter the server name (sql-prod-01.contoso.local), the database name (SalesDB), and the service account credentials. The browser encrypts these credentials with the gateway's public key before they are transmitted to Azure.
Data source SalesDB-Prod is registered and shows a green 'Connection Successful' status.
4
Step 4 — Publish the Report and Map the DatasetA report author publishes a Power BI Desktop (.pbix) file to a workspace. The dataset within this file references sql-prod-01.contoso.local. Power BI detects the on-prem connection string and prompts the user (or auto-maps if there is a matching gateway data source) to associate the dataset with the registered gateway and data source.
The dataset settings show: Gateway = Contoso-GW-01, Data Source = SalesDB-Prod.
5
Step 5 — Configure and Verify Scheduled RefreshUnder the dataset's scheduled refresh settings, the admin sets a daily refresh at 6:00 AM UTC. At that time, Power BI Service places a query request onto the Azure Service Bus relay. The gateway cluster picks it up, executes the M (Power Query) expressions against SQL Server, compresses the results, and pushes them back to the cloud. The dataset's cache is updated, and all reports and dashboards reflecting this dataset display the latest data.
Refresh history shows Completed with a duration of ~4 minutes and a row count of 2.3 M rows.

Strengths, Limitations & Mode Comparison

Each gateway mode comes with trade-offs. The following table consolidates the most decision-relevant attributes for architects and administrators evaluating gateway options.

Gateway mode comparison matrix
AttributeStandard (Enterprise)PersonalVNet
User ScopeMultiple users / org-wideSingle userMultiple users / org-wide
DirectQuery✓ Supported✗ Not supported✓ Supported
Clustering / HA✓ Multiple nodes✗ Single node✓ Azure-managed scaling
On-Prem HardwareRequired (Windows Server)Required (user workstation)Not required (Azure-hosted)
License RequirementPower BI Pro or PPUPower BI Pro or PPUPower BI Premium / Fabric capacity
Data SourcesOn-prem + private cloudOn-prem (user context)Azure VNet–peered resources
Admin OverheadMedium — patching, monitoringLow — user self-managesLow — Microsoft manages infra
🔧 DESIGN HEURISTIC
Think of the gateway mode decision like choosing between running your own Kubernetes cluster (Standard), running a single Docker container on your laptop (Personal), or using a fully managed serverless platform like Azure Container Apps (VNet). Each trades off control for convenience. Most production enterprises start with the Standard gateway for on-prem sources and adopt VNet gateways as they migrate workloads into Azure.

Connection to Advanced Architecture — Fabric, Dataflows & Hybrid Connectivity

The on-premises data gateway is not a standalone technology — it is a building block within Microsoft's broader data integration architecture. As organizations adopt Microsoft Fabric, Power BI Dataflows, and Azure Data Factory, the gateway continues to serve as the secure conduit for on-prem access. Understanding how gateways fit into these advanced scenarios is essential for architectural decisions at scale.

Gateway role in advanced data architectures
ConceptGateway RoleAdvanced Consideration
Power BI Dataflows (Gen2)Standard gateway executes M queries from dataflow definitions against on-prem sourcesDataflows can stage data in Azure Data Lake Storage Gen2, enabling incremental refresh patterns
Microsoft Fabric PipelinesGateway connects Fabric copy activities to on-prem SQL, Oracle, SAP, etc.Fabric can orchestrate complex ETL across on-prem and cloud in a single pipeline
Composite ModelsGateway supports DirectQuery connections to on-prem alongside imported Azure data in one modelEnables real-time operational data blended with historical cloud data in a single report
Azure ExpressRoute / VPNGateway communicates over Azure Service Bus; ExpressRoute optimizes latency but is not strictly requiredVNet gateways can leverage private peering for sub-millisecond latency to Azure PaaS services

Looking ahead, the trend is clear: Microsoft is investing in reducing the operational burden of gateways. VNet data gateways eliminate the need for on-prem hardware when sources are Azure-hosted. Managed private endpoints in Fabric allow datasets to connect to Azure SQL and Synapse without any gateway at all. However, for truly on-premises data — the SQL Server in the server room, the Oracle RAC cluster, the legacy AS/400 — the on-premises data gateway remains the indispensable bridge. As a computer science professional, you should view the gateway as an instance of a broader secure agent pattern that appears across distributed systems: Azure DevOps self-hosted agents, GitHub Actions runners, and Kubernetes Arc agents all follow the same outbound-only, relay-mediated communication model.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain why the on-premises data gateway uses outbound-only connections rather than requiring inbound firewall ports to be opened. What security principle does this design enforce?
PROBLEM 2BASIC CALCULATION
A Power BI dataset is configured with a scheduled refresh that runs 8 times per day. Each refresh transfers approximately 1.2 GB of compressed data through the gateway. The organization pays $0.087 per GB for outbound data transfer from their on-prem network (through their ISP). What is the monthly cost attributable to gateway data transfer alone (assume 30 days/month)?
PROBLEM 3INTERMEDIATE
An organization has both a Standard (Enterprise) gateway and a Personal gateway installed. A report author publishes a dataset that connects to an on-prem Oracle database. The dataset is shared with 15 colleagues in a workspace. The author initially configured the dataset to use their Personal gateway. What operational problems will arise, and what is the correct remediation?
PROBLEM 4APPLIED
You are a data engineer at a financial services company. Regulations require that customer PII (personally identifiable information) must never leave the corporate network in plaintext. Your team wants to build Power BI reports that aggregate customer data without exposing individual records. Design a gateway-based architecture that satisfies this constraint. Specify where aggregation occurs and what data passes through the gateway.
PROBLEM 5CRITICAL THINKING
The on-premises data gateway follows the same 'secure agent' design pattern as Azure DevOps self-hosted agents, GitHub Actions self-hosted runners, and Azure Arc–enabled Kubernetes agents. Identify the common architectural invariants across these systems. Then, analyze a potential vulnerability: if an attacker compromises the Azure Service Bus relay namespace, what is the maximum blast radius, and what mitigating controls exist in the gateway's design?

Lesson Summary

The on-premises data gateway is a software bridge that enables the Power BI Service to access data sources inside corporate firewalls. It uses outbound-only HTTPS connections to Azure Service Bus, ensuring no inbound firewall ports are needed. Credentials are protected by asymmetric RSA encryption — the private key never leaves the gateway machine, so Microsoft cannot decrypt stored credentials.

Three modes serve different needs: the Standard (Enterprise) gateway supports shared access, clustering for high availability, and both Import and DirectQuery modes. The Personal gateway is a single-user, import-only option for prototyping. The VNet data gateway is a fully managed Azure service for resources already within an Azure Virtual Network. The gateway embodies the secure agent pattern — the same outbound-relay architecture used by Azure DevOps agents, GitHub Actions runners, and Azure Arc — making it a foundational concept for hybrid cloud data engineering.

Varsity Tutors • Microsoft Power BI • Gateways — Understand gateway concepts for on-prem refresh (conceptual)