Copilot in Microsoft Fabric: generate notebooks and pipelines with AI
João Barros
20 de January de 2025
1 min read
Copilot in Microsoft Fabric is available in Spark notebooks and in Data Factory, offering real-time code assistance, generation of transformations from natural language and explanation of existing code.
Copilot in Notebooks
-- Prompt in the notebook chat:
"Create PySpark code to read all CSV files from the folder
Files/raw/sales/, remove duplicates by sale_id and save
in Delta format to the bronze_sales table with audit
columns (ingest_ts, source_file)"
-- Copilot generates:
from pyspark.sql.functions import current_timestamp, input_file_name
df = (spark.read
.format("csv")
.option("header", "true")
.option("inferSchema", "true")
.load("Files/raw/sales/*.csv")
.dropDuplicates(["sale_id"])
.withColumn("ingest_ts", current_timestamp())
.withColumn("source_file", input_file_name()))
df.write.format("delta").mode("append").saveAsTable("bronze_sales")
Explain existing code
// Select a code block → click "Explain" in Copilot
// Copilot explains in plain language what the code does, line by line
Fix errors automatically
// When a cell fails, the error banner includes
// a "Fix with Copilot" button — it analyzes the traceback
// and proposes a fix with an explanation
Copilot in Data Factory (Fabric)
Prompt: "Create a pipeline that reads data from the SQL Server table
dbo.Customers, filters records updated in the
last 24 hours and loads them into the Lakehouse
table silver_customers"
→ Copilot generates the pipeline with:
- Copy Activity (SQL Server → Lakehouse)
- Dynamic expression for the date filter
- Automatic schema mapping
Conclusion
Copilot in Fabric significantly speeds up repetitive data engineering tasks. Use it for initial scaffolding, explaining legacy code and fixing errors — but always review the generated code before promoting to production.