Dataflows Gen2 Ingestion

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 11 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Dataflows Gen2: Mastering Batch Data Ingestion

In the modern data landscape, the ability to move data from various sources into a centralized environment is the foundation of every successful analytics project. Before you can visualize trends, train machine learning models, or generate executive reports, you must first ingest and transform your raw data. Dataflows Gen2, a core component of the Microsoft Fabric ecosystem, represents a significant evolution in how data engineers and analysts handle batch ingestion. Unlike its predecessors, which were often constrained by platform limitations or siloed environments, Dataflows Gen2 provides a unified, low-code interface that bridges the gap between disparate data sources and the OneLake storage layer.

Understanding Dataflows Gen2 is critical because it democratizes the data ingestion process. By leveraging the familiar Power Query engine, users can perform complex data extraction, transformation, and loading (ETL) tasks without needing to write extensive custom code. This lesson explores the architecture, implementation, and optimization strategies for using Dataflows Gen2 to build reliable batch ingestion pipelines. Whether you are dealing with on-premises SQL databases, cloud-based APIs, or flat files stored in remote locations, mastering these tools will empower you to build scalable data solutions.

Not read yet

The Architecture of Dataflows Gen2

At its core, Dataflows Gen2 is a cloud-based service that executes Power Query scripts to ingest data. When you create a dataflow, you are essentially defining a series of steps—connecting to a source, applying transformations, and specifying a destination. The "Gen2" designation signifies a shift towards a more modular and performant architecture that integrates directly with the Fabric capacity.

One of the most important aspects of Dataflows Gen2 is its ability to handle "staging." In previous versions of dataflows, the transformation and the landing of data were often tightly coupled. In Gen2, you have explicit control over the staging process. By using the staging area, you can optimize performance, as the data is first ingested into a managed storage environment before being processed further. This separation of concerns allows for more complex workflows, such as multi-stage transformations where you clean data in one step and aggregate it in another.

Callout: Dataflows Gen1 vs. Dataflows Gen2 While Dataflows Gen1 was primarily designed for Power BI datasets, Dataflows Gen2 is a platform-wide tool for data integration. Gen1 dataflows often struggled with large volumes because they were tied to the Power BI service's capacity limits. Gen2, however, is built on the Fabric engine, allowing for better parallel processing, improved connectivity to Lakehouses and Warehouses, and a more granular control over refresh schedules and error handling.

Key Components of the Dataflow Interface

When you open the Dataflows Gen2 editor, you are greeted with a Power Query interface that should be familiar to anyone who has used Excel or Power BI. However, the functionality here is expanded to support the broader Fabric ecosystem. The interface is divided into three primary areas:

  • The Data Source Navigator: This allows you to select from hundreds of built-in connectors. Whether you are connecting to an OData feed, an Azure SQL database, or a CSV file on SharePoint, the connection experience remains consistent.
  • The Power Query Editor: This is the heart of the ingestion process. Here, you define your transformations using the M language under the hood. You can filter rows, pivot columns, merge queries, and perform complex conditional logic.
  • The Destination Settings: Unlike previous versions, Gen2 allows you to explicitly choose where your data lands. You can output to a Lakehouse, a Data Warehouse, or even another dataflow. This makes it an ideal tool for "staging" data before it is consumed by downstream analytics.

Not read yet

Step-by-Step: Creating Your First Ingestion Pipeline

To begin using Dataflows Gen2, you must first have access to a Fabric workspace. The process follows a logical flow: connecting, transforming, and loading.

Phase 1: Connecting to Data

  1. Navigate to your Fabric workspace and select "New."
  2. Choose "Dataflow Gen2" from the list of options.
  3. In the Power Query ribbon, select "Get Data."
  4. Choose your data source (e.g., Azure SQL Database).
  5. Provide the credentials. It is highly recommended to use Organizational Accounts or Service Principals rather than hardcoded credentials to maintain security.

Phase 2: Applying Transformations

Once connected, you will see a preview of your data. The goal of the transformation phase is to ensure the data is in the correct format for your target schema.

  • Data Type Enforcement: Always ensure that columns like dates, integers, and decimals are correctly typed. Inconsistent data types are the most common cause of pipeline failures.
  • Column Selection: Only ingest the columns you actually need. Bringing in unnecessary data increases the time it takes for the refresh to complete and consumes additional compute resources.
  • Filtering: Apply filters as early as possible in the query process. If you only need data from the last 30 days, filter the dates immediately after connecting to the source.

Phase 3: Setting the Destination

This is the defining feature of Gen2. Click on the "Data destination" icon in the Queries pane. Select your target Lakehouse or Warehouse. You will then be prompted to map your query columns to the destination table columns. You can choose to "Append" data to an existing table or "Replace" the entire table during each refresh.

Tip: Use Dataflows for Staging If you are working with complex data transformations, do not try to do everything in a single dataflow. Create one dataflow that ingests the raw data into a "Staging" table in your Lakehouse. Then, use a second dataflow or a notebook to perform the heavy transformation. This makes debugging significantly easier because you can inspect the raw data before the transformations occur.

Not read yet

Best Practices for Batch Ingestion

Ingestion is not just about moving data; it is about moving data efficiently and reliably. In a production environment, you need to account for network latency, source system availability, and data quality issues.

1. Incremental Refresh

One of the biggest mistakes developers make is performing a "full load" on every run. If you have a table with millions of rows, refreshing the entire dataset every hour is a massive waste of resources. Instead, implement incremental refresh. You can use parameters in Power Query to filter data based on a "LastModified" or "TransactionDate" column. By only pulling the data that has changed since the last run, you drastically reduce the load on the source system and the time required for the dataflow to complete.

2. Handling API Rate Limits

When ingesting data from external APIs, you are often subject to rate limits. If your dataflow attempts to pull too much data at once, the API may block your connection. To avoid this, implement "throttling" by breaking your requests into smaller chunks. You can use the List.Generate function in M to iterate through pages of data, adding a small delay between requests if necessary.

3. Error Handling and Logging

Dataflows Gen2 provides a "View Errors" feature, but you should not rely on it for production monitoring. Implement robust error handling by creating "error-catching" columns. For example, if you are performing a division operation, use a conditional column to check for zeros before the math occurs. This prevents the entire dataflow from failing due to a single bad record.

4. Parameterization

Never hardcode server names, database names, or file paths within your queries. Always use the "Manage Parameters" feature. This allows you to change the environment (e.g., switching from a development database to a production database) by simply updating the parameter values, rather than rewriting your entire query logic.

Not read yet

Common Pitfalls and How to Avoid Them

Even with the best tools, issues will arise. Being aware of these common traps will save you hours of troubleshooting.

  • The "Fold" Failure: Power Query is designed to "fold" operations back to the source system. If you perform a transformation that the source system cannot understand (like a complex custom Python script), the dataflow will pull all the data into the Fabric memory to process it. This is called "breaking query folding." Always check the "Applied Steps" pane; if the "View Native Query" option is grayed out, your query is no longer folding. This can lead to significant performance degradation.
  • Data Type Mismatches: If your source SQL database has a column defined as VARCHAR but contains numeric data, and your destination Lakehouse table expects an INTEGER, the ingestion will fail. Always explicitly change data types in Power Query to match the target schema.
  • Timezone Issues: When dealing with global data, timezones are a constant source of frustration. Always convert your timestamps to UTC at the earliest possible stage in your ingestion pipeline. This ensures consistency across all downstream reporting.

Not read yet

Advanced Dataflow Techniques: M Language

While the UI is powerful, the M language allows for advanced logic that the click-and-drag interface cannot handle. Understanding the basics of M is essential for any serious data professional.

Consider a scenario where you need to ingest files from a folder where the filenames contain a date (e.g., Sales_2023_10_01.csv). You can use M to dynamically construct the file path based on the current date:

let
    // Get the current date
    Today = DateTime.LocalNow(),
    // Format the date to match the filename structure
    DateString = Date.ToText(Today, "yyyy_MM_dd"),
    // Construct the full file path
    FilePath = "https://yourstorage.blob.core.windows.net/data/Sales_" & DateString & ".csv",
    // Connect to the file
    Source = Csv.Document(Web.Contents(FilePath))
in
    Source

This snippet demonstrates how to make your ingestion dynamic. Instead of manually updating the file path every day, the dataflow automatically adjusts to the current date, ensuring that your batch process is truly automated.

Warning: Performance and Memory Dataflows Gen2 run in a containerized environment. If you are processing extremely large datasets, you might hit memory limits. If you find your dataflow crashing frequently, consider splitting your logic into smaller, more focused dataflows that run sequentially or in parallel, rather than one giant, monolithic dataflow.

Not read yet

Comparison: Choosing the Right Tool for Ingestion

It is important to understand when to use Dataflows Gen2 versus other tools like Data Pipelines or Notebooks.

Feature Dataflows Gen2 Data Pipelines Notebooks (Spark)
Primary Use Low-code ETL Orchestration High-code, Big Data
Skill Level Low Low/Medium High
Performance Good for medium data High for orchestration Best for massive scale
Complexity Simple transformations Moving files/triggers Complex logic/ML

If your task is to simply move a few hundred megabytes of data from a SQL database to a Lakehouse while cleaning up some column names, Dataflows Gen2 is the perfect tool. If you need to orchestrate a complex workflow that involves triggering an external API, copying files, and then running a machine learning model, use Data Pipelines. If you are processing terabytes of unstructured data, you should use Spark Notebooks.

Industry Standards for Data Ingestion

In professional environments, data ingestion is treated as a software engineering discipline. This means following standards that go beyond just "making it work."

Data Contract Enforcement

A data contract is an agreement between the data producer (the source system) and the data consumer (the analytics team). Before starting your ingestion, define what the data should look like. If the source system changes a column name, your Dataflow Gen2 will break. By having a contract, you ensure that any changes are communicated in advance, allowing you to update your dataflow proactively.

Monitoring and Alerting

Fabric provides built-in monitoring for dataflows, but it is often reactive. You should configure alerts so that if a dataflow fails, an automated notification is sent to the responsible team. This can be achieved through Fabric's integration with automated workflows, allowing you to catch issues before they affect end-user reports.

Security and Governance

Never store passwords in your dataflow queries. Use Key Vaults or managed identities whenever possible. Furthermore, ensure that the dataflow is running under a service account that has "Least Privilege" access. If a dataflow only needs to read from a table, do not grant it "Owner" or "Write" permissions on the source database.

Not read yet

Troubleshooting Common Issues

Even the best-designed pipelines encounter errors. When a Dataflow Gen2 fails, start with these steps:

  1. Check the Refresh History: Look at the error message provided in the Fabric monitor. It will often point to a specific step in the M query that failed.
  2. Test in Power BI Desktop: If you are unsure why a query is failing, copy the M code into Power BI Desktop. The error messages in Desktop are often more descriptive than those in the web-based Dataflow editor.
  3. Inspect the Data Source: Sometimes the issue isn't your code; it is the source system. Check if the database was under maintenance or if the API was rate-limiting your requests.
  4. Validate Data Samples: If your query works on a small sample but fails on the full dataset, you likely have "dirty data" (e.g., a text string in a column that is supposed to be numeric). Use a "Keep Errors" step in Power Query to isolate the rows that are causing the failure.

Callout: The Power of "Keep Errors" When debugging a dataflow, you can right-click a column and select "Keep Errors." This creates a new table containing only the rows that caused an error during processing. This is a highly effective way to identify exactly which records are violating your schema rules without having to manually scan through millions of rows.

Not read yet

Scaling Your Data Ingestion Strategy

As your organization grows, the number of dataflows will increase. Managing dozens or hundreds of dataflows requires a structured approach to naming conventions and workspace organization.

  • Naming Conventions: Adopt a strict naming convention, such as [SourceSystem]_[EntityName]_[Frequency]. For example, SAP_SalesOrders_Daily is much easier to manage than Dataflow1.
  • Modular Design: As mentioned previously, break large dataflows into smaller ones. You can use the "Output" feature of one dataflow to feed into another, creating a chain of dependencies that is easier to maintain than a single, massive process.
  • Environment Management: Use Fabric Deployment Pipelines to move your dataflows from Development to Test to Production. This ensures that your connections and parameters are updated automatically as you promote your code through the different stages.

Not read yet

The Future of Ingestion: AI Integration

The landscape of data ingestion is changing rapidly with the inclusion of AI. Microsoft is increasingly integrating Copilot-style features into Power Query. This means you will eventually be able to describe your transformation in plain English (e.g., "Remove the first three rows and split the date column by the hyphen") and have the M code generated for you. While this does not replace the need for understanding the fundamentals, it will significantly speed up the initial development phase of your ingestion pipelines.

Practical Example: A Real-World Scenario

Imagine you are working for a retail company. You need to ingest daily sales data from an on-premises SQL Server and inventory data from an external API.

  1. SQL Server Ingestion: You create a Dataflow Gen2 that connects to the on-premises gateway. You use an incremental refresh strategy based on the TransactionDate column. The destination is set to the Sales_Staging table in your Lakehouse.
  2. API Ingestion: You create a second Dataflow Gen2 that calls the inventory API. You use the List.Generate function to handle pagination. You transform the JSON response into a flat table and save it to the Inventory_Staging table in the same Lakehouse.
  3. Transformation: You use a third Dataflow Gen2 to join the Sales_Staging and Inventory_Staging tables. You perform a left join to see which sales occurred for items that were in stock. You then output this to a final Sales_Analysis table.

This workflow is clean, modular, and easy to maintain. If the API changes its format, you only need to update the second dataflow. If the SQL Server connection is slow, you only need to optimize the first dataflow. This is the essence of professional data engineering.

Not read yet

Key Takeaways

  1. Dataflows Gen2 is a foundational tool: It provides a low-code, powerful interface for batch ingestion within the Fabric ecosystem, bridging the gap between raw data and your Lakehouse or Warehouse.
  2. Master the separation of concerns: Use Dataflows Gen2 for staging raw data first, then perform complex transformations in subsequent steps. This modularity makes debugging and maintenance much simpler.
  3. Prioritize performance: Implement incremental refreshes to avoid loading entire datasets, and always be mindful of query folding to ensure your transformations are executed at the source whenever possible.
  4. Embrace M for advanced logic: While the UI is excellent, learning the basics of the M language allows you to handle dynamic file paths, complex API pagination, and conditional logic that the standard interface cannot handle alone.
  5. Governance is non-negotiable: Use parameters, service principals, and key vaults to ensure your ingestion pipelines are secure and portable across development, test, and production environments.
  6. Data quality is a shared responsibility: Always implement error handling within your dataflows to catch bad data early, and use the "Keep Errors" feature to troubleshoot problematic records efficiently.
  7. Think in pipelines, not just tables: Treat your data ingestion as a professional software project by using consistent naming, modular designs, and robust monitoring to ensure long-term reliability.

By following these principles and mastering the mechanics of Dataflows Gen2, you position yourself to build data architectures that are not only efficient but also resilient to the changing needs of your organization. Start by applying these concepts to a small project, and as you become comfortable, scale your efforts to handle more complex and high-volume data challenges. The transition from "moving data" to "engineering data flows" is the hallmark of a senior data professional.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.