Dr. Estera Kot

FabCon Europe 2026 in 18 demos · Part 17 of 18 · Engineering building blocks

AI functions in Spark: translate, classify, and score sentiment in one line

Three model calls chained on one DataFrame column, with no API key, billed to your capacity.

By Dr. Estera Kot, Microsoft MVP, CTO at Clouds on Mars, and former Microsoft Principal Product Manager for the Apache Spark runtime in Fabric. Published .

AI functions in Microsoft Fabric are DataFrame methods that send each value of a text column to a large language model and write the answer to a new column. You call df.ai.translate(), df.ai.analyze_sentiment(), or df.ai.classify() in a pandas or PySpark notebook. A built-in endpoint serves the model, so you need no Azure OpenAI resource and no API key.

This note covers demo 15 of FabCon Europe 2026 in 18 demos: text enrichment that runs where the data sits.

In short

  1. One line per function enriches a column through a built-in endpoint: no API key, gpt-5-mini by default, billed on the Copilot and AI meter.
  2. Column values go to Azure OpenAI in the US or the EU Data Boundary. Capacities elsewhere, the UK included, need an admin to allow cross-geo processing.
  3. Bring your own Azure OpenAI or Foundry resource for another model, provider billing, or a resource you control. You then manage a key.
The notebook 04_ai_functions chains ai.translate, ai.analyze_sentiment, and ai.classify over eight synthetic tester comments in English, Arabic, and French. The Spark wait is sped up. 29 seconds, no sound, recorded Oct 21, 2026.

Same demo in Polish and German. Step-by-step runbook: D15.

What Fabric AI functions are and how they work

Learn lists nine AI functions. Each is a prebuilt model transformation that takes a column plus options such as a target language or labels.

The PySpark version runs as a distributed Spark transformation. Each worker sends rows as asynchronous requests, 200 at a time by default and up to 1,000 with concurrency. The pandas version runs on one node. Each call adds an output column, null when the model can’t decide, and an error column. PySpark results keep the df.ai accessor, so the demo chains three calls in one expression.

How one AI function call travels from Spark to the model and back A DataFrame of eight comments goes to Spark workers, which run ai.translate, ai.analyze_sentiment, and ai.classify. Workers send row text to the built-in Fabric endpoint, operated by Microsoft, which runs gpt-5-mini in Azure OpenAI in the US or the EU Data Boundary and bills the Copilot and AI meter. Answers return to Spark as new columns. As an alternative, workers can call your own Azure OpenAI or Foundry resource with your key. Your notebook and capacity Built-in Fabric endpoint Spark compute bills on the Spark meter. Operated by Microsoft. No API key. comments 8 rows, synthetic OB-104EN OB-101EN OB-106AR OB-103EN OB-102AR OB-104EN OB-105AR OB-106FR Spark workers .ai.translate() .ai.analyze_sentiment() .ai.classify() Rows leave as async requests: 200 per worker by default, up to 1,000 with concurrency. row text answer gpt-5-mini reasoning effort low, by default Azure OpenAI in US datacenters or the EU Data Boundary Copilot and AI meter, operation “AI Functions” No logging of prompts or outputs result formula_id | comment_en | sentiment | topic plus an error column per call, null when the model can’t decide Or your own resource Azure OpenAI or Foundry: your URL, your key, your provider’s token bill How one AI function call travels from Spark to the model and back Top to bottom: eight comments, Spark workers running three AI functions, the built-in Fabric endpoint operated by Microsoft with gpt-5-mini in the US or the EU Data Boundary, the alternative of your own resource, and the result columns. Operated by Microsoft Your notebook, capacity, or resource comments 8 rows in English, Arabic, and French formulas OB-101 to OB-106, synthetic Spark workers .ai.translate() .ai.analyze_sentiment() .ai.classify() 200 requests per worker by default, up to 1,000 with concurrency row text Built-in endpoint: gpt-5-mini reasoning effort low, no API key Azure OpenAI in US datacenters or the EU Data Boundary Copilot and AI meter, operation “AI Functions” or Your own resource Azure OpenAI or Foundry: your URL, key, and your provider’s token bill answer result comment_en, sentiment, topic plus an error column per call, null when the model can’t decide
Figure 1. Spark sends row text to the built-in endpoint and writes each answer to a new column.

Learn supports AI functions on Fabric Runtime 1.3 and later. Setup differs by API and runtime:

IDAPI and runtimeImportInstall first
V1PySpark, any Fabric Spark runtimesynapse.ml.spark.aifuncNothing
V2pandas, other PySpark runtimessynapse.ml.aifuncNothing for most usage
V3pandas, Runtime 2.0synapse.ml.aifuncnest_asyncio, temporarily
V4pandas, Python runtimesynapse.ml.aifuncTwo SynapseML wheels
V5Either API, Runtime 2.0BothA cell that sets the model

What the AI functions demo shows

One Run all on eight synthetic tester comments about oud formulas OB-101 to OB-106.

  1. 0:00 Cell 1 of 04_ai_functions imports synapse.ml.spark.aifunc, sets gpt-5-mini with low reasoning effort, and builds the DataFrame comments.
  2. 0:02 Run all. At 0:04 a notice reads “Session started in 5 sec.”
  3. 0:05 Cell 1 returns 2 columns and 8 rows. Cell 2 starts, and the wait is sped up.
  4. 0:14 Cell 2 chains the three functions. Its status line shows the real run time, 1 min 0 sec.
  5. 0:15 The result prints, then “done: 8 comments,” on screen until 0:28.

Arabic and French comments return in English. OB-106’s Arabic comment reads “The scent of oud is strong and long-lasting, I liked it a lot,” positive, longevity. English passes through unchanged.

OB-105, “I don’t notice any difference from the reference perfume,” scores negative where a reviewer could say neutral. Learn’s examples say: “Always review output for mistakes.”

Fabric notebook cell with three chained AI function calls and its output: formula_id, comment_en, sentiment, and topic for eight comments, run time 1 min 0 sec
The result at 0:20: English text, sentiment, and one topic per comment.

What AI functions cost

AI functions need F2 or larger, or any P SKU, and the tenant setting “Users can use Copilot and other features powered by Azure OpenAI,” on by default. Trial SKUs can’t use the built-in endpoint.

Spark compute bills on the Spark meter. Model calls bill on the Copilot and AI meter, as the operation “AI Functions” in the Capacity Metrics app, in CU seconds per 1,000 tokens:

IDModelInputCached inputOutput
R1gpt-5-mini, default8.400.8467.23
R2gpt-5.142.024.20336.13

Output costs about eight times as much as input, and Learn says rates can change. Read ai.stats on the result for token counts and failed rows.

Where your text goes

AI functions send cell values to the model. Your capacity’s geography decides where the built-in model runs.

  1. USUSNone
  2. EU Data BoundaryEU Data BoundaryNone
  3. UKEU Data BoundaryEnable cross-geo processing
  4. Ten other geographiesAustralia, Brazil, Canada, India, Asia, Japan, Korea, South Africa, Southeast Asia, United Arab EmiratesUSEnable cross-geo processing
Figure 2. Where the built-in model processes column values, per Learn. Dashed red routes leave the geography.

The cross-geo setting is “Data sent to Azure OpenAI can be processed outside your capacity’s geographic region, compliance boundary, or national cloud instance,” off by default. Learn states that AI functions don’t log or store prompts, inputs, or outputs.

When to bring your own model

The pandas and PySpark versions can call any model with the responses or chat_completions API, such as Azure OpenAI or a Foundry model like LLaMA, directly or through Azure API Management.

IDQuestionBuilt-in endpointYour own resource
E1SetupNoneset_URL and set_subscription_key
E2Model calls billed toYour capacityYour provider. Fabric charges none.
E3Prompts processed inUS or EU Data BoundaryThe resource you deploy
E4ai.embed, ai.similaritySupportedNot with a custom Foundry resource
Figure 3. Built-in endpoint or your own resource, question by question.

Switch for a missing model, provider billing, or a policy that allows only your own resource. Then read the key from Azure Key Vault at run time.

Limits and catches

The catch: on Runtime 2.0, Learn tells you to set the model, reasoning effort, and temperature in code at the start of every session, as a temporary workaround. The demo’s first cell does exactly that.

For plain-language questions over a lakehouse, use the Fabric data agent.

Run the demo yourself

python3 fabdemo.py up from the recap repo builds the workspace, the lakehouse lh_oud_rd, and the notebook 04_ai_functions on an F8 capacity. With the tenant setting above on, open the notebook, select Run all, and scroll to the result.

# Tester comments from the Doha panel (synthetic data): English, Arabic, French
import warnings; warnings.filterwarnings("ignore")
import synapse.ml.spark.aifunc as aifunc
aifunc.default_conf.set_deployment_name("gpt-5-mini")   # Runtime 2.0: model set explicitly (Learn, temporary)
aifunc.default_conf.set_reasoning_effort("low")
aifunc.default_conf.reset_temperature()

comments = spark.createDataFrame([
    ("OB-104", "The opening is smoky and rich, I would wear this to a wedding."),
    ("OB-101", "Too sweet after an hour, the rose disappears."),
    ("OB-106", "رائحة العود قوية وثابتة، أحببتها كثيراً"),
    ("OB-103", "Nice but nothing special compared to the reference."),
    ("OB-102", "الافتتاحية حادة جداً، تحتاج إلى نعومة أكثر"),
    ("OB-104", "The saffron note is beautiful and lasts all day on the skin."),
    ("OB-105", "لا أشعر بأي فرق عن العطر المرجعي"),
    ("OB-106", "Le bois de oud est magnifique, très élégant.")
], ["formula_id", "comment"])
display(comments)
# One line per AI function: translation, sentiment, topic
result = (comments
    .ai.translate(to_lang="english", input_col="comment", output_col="comment_en")
    .ai.analyze_sentiment(input_col="comment", output_col="sentiment")
    .ai.classify(input_col="comment", labels=["scent note", "longevity", "sweetness", "no difference"], output_col="topic"))

result.select("formula_id", "comment_en", "sentiment", "topic").show(truncate=False)
print("done:", result.count(), "comments")

Expected result: eight comments with a translation, a sentiment, and a topic from your labels, then done: 8 comments.

Time and cost: about 4 minutes on that F8 capacity, per runbook D15. The recap README puts F8 at about 1.41 EUR per hour in France Central at the Azure retail price on October 21, 2026.

What to do on Monday

On Monday: Pilot one AI function on one text column in a dev workspace, and read ai.stats for token use before you schedule the notebook.

Key facts at a glance

Checked on Microsoft Learn on November 3, 2026.

IDFactSource
K1Nine functions, among them translate, analyze_sentiment, and classifyLearn: overview
K2Default model gpt-5-miniLearn: overview
K3F2 or larger, or a P SKU. No trial SKUs.Learn: Copilot in Fabric
K4Runtime 1.3 and later, Runtime 2.0 with a temporary setupLearn: Runtime 2.0
K5200 concurrent rows per worker by default, up to 1,000Learn: PySpark configuration
K6Copilot and AI meter, operation “AI Functions”Learn: billing
K7gpt-5-mini: 8.40 CU seconds per 1,000 input tokens, 67.23 per 1,000 output tokensLearn: billing
K8Built-in model in the US and the EU Data BoundaryLearn: Copilot in Fabric

Frequently asked questions

Do Fabric AI functions need an API key?

No, not with the built-in endpoint. Fabric sets it up and bills model calls to your capacity. You need a key only for your own Azure OpenAI or Microsoft Foundry resource.

Which Fabric runtimes support AI functions?

Fabric Runtime 1.3 and later. On Runtime 2.0, Learn prescribes a temporary setup cell that sets the model, reasoning effort, and temperature, plus nest_asyncio for pandas.

How are Fabric AI functions billed?

Built-in model calls consume capacity on the Copilot and AI meter, shown as the AI Functions operation. gpt-5-mini costs 8.40 CU seconds per 1,000 input tokens and 67.23 per 1,000 output tokens. Spark compute bills separately.

Where is my data processed when I use AI functions?

In US datacenters or the EU Data Boundary. US and EU Data Boundary capacities stay in their geography. Capacities elsewhere, the UK included, need the cross-geo processing tenant setting.

Are AI functions in Fabric generally available?

Yes, for pandas and PySpark. The Microsoft Fabric Updates Blog announced GA on November 19, 2025. Multimodal input and warehouse T-SQL functions are in preview as of November 3, 2026.

About the author

Dr. Estera Kot is CTO at Clouds on Mars, a Microsoft and Databricks partner for data and AI in Europe and the Middle East. At Microsoft she was Principal Product Manager for the Apache Spark runtime in Azure Synapse Analytics and Microsoft Fabric, and she created the Native Execution Engine. She is a Microsoft MVP and holds a Ph.D. in Computer Science from the Warsaw University of Technology. She presented this series as the FabCon Europe 2026 recap in Gdynia on October 21, 2026, and online on October 23, 2026. Slides, recordings, and runbooks are in the public recap repository.

Sources

Microsoft Learn and the Microsoft Fabric blog, checked on November 3, 2026.