Spark CLI
MicrosoftOfficialPublished by Microsoft
- Skill
- Tool integration
- Software development
- MIT
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
spark-cli is a mode-based dispatcher designed to handle the full lifecycle of Fabric Spark operations. It provides structured guidance for authoring notebook code, managing interactive Livy sessions, diagnosing Spark job failures, and operating Materialized Lake Views (MLV). The skill enforces strict operational boundaries, requiring users to select a specific mode (authoring, consumption, operations, or mlv) and consult the corresponding reference documentation before executing any commands to ensure correct API usage and payload construction.
What it does
- Authors and manages Fabric notebook cell code including PySpark, Scala, and %%sql.
- Facilitates interactive data analysis through Livy session management.
- Diagnoses failed, slow, or OOM Spark jobs and pipeline runs.
- Manages the complete lifecycle of Materialized Lake Views, including definition, scheduling, and refresh monitoring.
- Provides standardized patterns for data engineering, schema management, and error handling in Fabric.
- Ensures proper telemetry and authentication for all Fabric API interactions.
When to use it
- When writing or updating code within Fabric notebooks.
- When performing ad-hoc data analysis using interactive Livy sessions.
- When investigating performance bottlenecks or failures in Spark jobs.
- When creating, scheduling, or troubleshooting Materialized Lake Views.
- When you need to ensure your Fabric API calls follow mandatory telemetry and authentication standards.
Advantages
- Provides a structured, mode-based approach to prevent configuration errors.
- Centralizes complex Spark and MLV management tasks into a single interface.
- Enforces best practices for data engineering and schema management.
- Reduces ambiguity by clearly defining the scope of Spark-related operations versus other CLI tools.
Usage examples
- “Write a notebook cell that reads a bronze table and writes a silver Delta table.”
- The agent enters 'authoring' mode, reads the relevant reference, and generates the appropriate PySpark code using Delta Lake patterns.
- “My notebook run failed with an OOM error, can you help me diagnose it?”
- The agent enters 'operations' mode, reads the diagnostic workflow reference, and guides the user through analyzing the job logs and metrics.
- “Schedule a nightly refresh for the lakehouse MLV and show me its run history.”
- The agent enters 'mlv' mode, reads the MLV reference, and executes the necessary API calls to configure the schedule and retrieve the history.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/microsoft/spark-cli/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip spark-cli.zip -d .agents/skills
Documentation by Microsoft
Telemetry — MANDATORY. Every
api.fabric.microsoft.comcall must carryx-ms-fabric-skill: spark-cli(az rest:--headers "x-ms-fabric-skill=spark-cli"), including every LRO poll,fabric_lroand retry. Snippets omit it — add it anyway.
CRITICAL NOTES
To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering
To find the item details (including its ID) from workspace ID, item type, and item name: list all items of that type in that workspace and, then, use JMESPath filtering
Skill disambiguation: use
spark-clifor notebook cell code (including%%sqlcells), named notebook runs, Livy sessions, Spark failure triage, and everything about a Materialized Lake View -- writing the definition, reviewing a query for incremental-refresh readiness, and scheduling, refreshing, monitoring or diagnosing an existing one. A KQL materialized view in an Eventhouse iseventhouse-cli; plain read-only T-SQL against a Warehouse or Lakehouse SQL endpoint issqldw-cli.Hard routing boundary: never execute an Eventhouse/KQL materialized-view request from this skill. Route it to
eventhouse-cli; if that skill is unavailable, state that the request cannot be completed in the current skill context and stop without calling Fabric APIs or creating artifacts.
Fabric Spark and Materialized Lake Views -- CLI Skill
This one skill owns Fabric Spark: notebook cell authoring, notebook runs, Livy-session analysis, Spark failure diagnostics, and the whole Materialized Lake View lifecycle.
It is a mode dispatcher and contains NO procedures. Pick the mode that matches the request from the table below, then read the matching references/<mode>.md file end to end with your file-reading tool BEFORE issuing a single command. That file holds the endpoints, payload shapes, templates and gotchas; acting without it produces wrong payloads and wrong results.
Mode selection
| Mode | Use when the request ... | Example triggers | Read this first |
|---|---|---|---|
authoring | writes notebook cell code (PySpark, Scala, SparkR, %%sql, %%configure), runs a notebook by name and reports a NORMAL run status, or authors a Materialized Lake View definition or reviews an MLV query for incremental-refresh readiness | write notebook code, notebook cell code, %%sql cell, run notebook, execute notebook, notebookutils, create materialized lake view, is this MLV query incremental-refresh ready | references/authoring.md |
consumption | runs interactive ad-hoc PySpark in a Lakehouse Livy session -- never a notebook | create a Livy session, run calculation in Livy, PySpark, DataFrame analysis, join tables across lakehouses, Delta time-travel | references/consumption.md |
operations | diagnoses a FAILED, unhealthy, throttled or slow Spark notebook / pipeline / Livy run | failed notebook, Spark Livy health, Spark OOM, why is my notebook slow, job diagnostics, 430 throttling | references/operations.md |
mlv | discovers or operates EXISTING Materialized Lake Views: Spark SQL discovery, refresh schedules, on-demand refresh, run history, cancellation, and refresh-failure classification | discover MLVs, list materialized lake views, schedule MLV, MLV run history, cancel refresh, trigger MLV refresh, diagnose MLV refresh failure | references/mlv.md |
Mode boundary rule
Mode is decided by the artefact and the outcome, not by the language. A notebook cell is always authoring even when the cell is %%sql. A Livy session is always consumption. A Spark run that FAILED or is unhealthy is operations; a run that succeeded is reported by authoring. For a Materialized Lake View the VERB decides: writing or reviewing the definition is authoring, while discovering, scheduling, refreshing, monitoring or diagnosing existing MLVs is mlv. If discovery must be executed, switch to consumption for Livy or authoring for a notebook only after reading the discovery command from references/mlv.md.
If a request genuinely spans modes, handle them one at a time and read each reference before you start that part. If the mode is ambiguous after reading this table, ask one short clarifying question instead of guessing.
Terminal write -- the step you must not skip
Reading the reference and planning the change is NOT completing the task. Each mutating mode ends with one state-changing call. If you did not issue it, nothing was persisted -- say so explicitly rather than reporting success.
| Mode | Terminal write |
|---|---|
authoring | for an EXISTING notebook, POST .../notebooks/{id}/updateDefinition to save the cell; a NEW notebook needs POST /v1/workspaces/{ws}/items first; for a run request, trigger the job via the Jobs API. Printing cell code into the chat is not saving or running it. |
consumption | none -- this mode is read-only |
operations | none -- this mode is read-only |
mlv | POST /v1/workspaces/{ws}/lakehouses/{lakehouse}/jobs/refreshMaterializedLakeViews/instances for an on-demand refresh, or the schedule create/update/delete call for a scheduling request. Reporting what the schedule would be is not creating it. |
Before you report the task done, confirm the terminal call returned success and, where the reference documents a readback, read the artefact back to prove the change landed.
Shared essentials (all modes)
Resolve the workspace and item first; every mode depends on it.
| Task | Reference | Notes |
|---|---|---|
| Finding Workspaces and Items in Fabric | COMMON-CLI.md | Mandatory -- read before resolving any workspace or item id |
| Fabric Topology & Key Concepts | COMMON-CORE.md | Item types, workspaces, capacities |
| Environment URLs | COMMON-CORE.md | Sovereign / non-public cloud hosts |
| Authentication & Token Acquisition | COMMON-CORE.md | Wrong audience = 401; read before any auth issue |
| Authentication Recipes | COMMON-CLI.md | az login flows and token acquisition |
| Core Control-Plane REST APIs | COMMON-CORE.md | Pagination, LRO polling, rate limiting |
| Gotchas & Troubleshooting | COMMON-CLI.md | az rest audience, shell escaping, token expiry |
Rules
MUST
Select exactly one mode from the table above before doing anything else.
Treat vague requests such as "set up my data" as insufficiently scoped. Ask what artefact, source, destination, and outcome the user wants; never infer intent by finding and running an existing notebook or job.
Read
references/<mode>.mdend to end, as your FIRST tool call, before the first command of that mode. Read it ONCE, in a single full read: do not re-open it, do not grep it again, and do not page through it. You already have it.Apply the same read-once discipline to every other file you load, including nested
references/<mode>/*.mdsub-references and sharedcommon/*.mdfiles: open only the ones you actually need, read each ONCE end to end, and never grep or re-open one you already loaded.Resolve workspace and item ids by listing and filtering, never by guessing a GUID.
Stop after routing any Eventhouse/KQL materialized-view request. Unavailable sibling skills are a blocking boundary, not permission to implement their workload directly.
Announce a mode switch explicitly when the request crosses a boundary.
Treat the reference as instructions, never as the deliverable. After reading it, RUN the documented commands against the live workspace and report the real results. Quoting what the reference says instead of executing it does not answer the request.
PREFER
The narrowest mode that satisfies the request.
Reading exactly ONE mode reference. Load a second only when the request genuinely spans modes, and say so before you do.
Reporting the mode you chose in your first response so the user can correct you.
AVOID
Acting from this dispatcher alone -- it intentionally omits the operational detail.
Answering with a summary of the reference instead of executing it.
Re-reading or re-grepping a reference you already loaded; it costs turns and tokens.
Mutating anything while in a read-only mode.
Loading a different skill for work this family already owns (see CRITICAL NOTES 3).
Attempting an out-of-scope request through raw REST calls when the owning skill is unavailable. Name the owning skill and stop; do not improvise by creating Fabric artefacts outside
spark-cli's scope.
Examples
| User request | Mode | Reference to read |
|---|---|---|
| "Write a notebook cell that reads the bronze table and writes a silver Delta table." | authoring | references/authoring.md |
| "Create a Livy session and count the distinct customers in the lakehouse." | consumption | references/consumption.md |
| "My notebook run failed with an OOM -- work out why." | operations | references/operations.md |
| "Is this materialized lake view query ready for incremental refresh?" | authoring | references/authoring.md |
| "Show me the Spark SQL command that lists the MLVs in schema silver." | mlv | references/mlv.md |
| "Schedule a nightly refresh for the lakehouse MLV lineage and show me its run history." | mlv | references/mlv.md |
Files
- ATTRIBUTION.mdAdded by AutoGineer863 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md10.1 KiB
- apm.yml430 B
- references/authoring.md32.9 KiB
- references/authoring/resources/data-engineering-patterns.md24.3 KiB
- references/authoring/resources/development-workflow.md7.4 KiB
- references/authoring/resources/infrastructure-orchestration.md10.4 KiB
- references/authoring/resources/materialized-lake-view-patterns.md20.1 KiB
- references/authoring/resources/mlv-incremental-refresh-patterns.md11.4 KiB
- references/authoring/resources/notebook-api-operations.md14.2 KiB
- references/consumption.md12.3 KiB
- references/mlv.md32.8 KiB
- references/operations.md20.3 KiB
- references/operations/automated-diagnostic-workflow.md12.7 KiB
- references/operations/diagnostic-workflow.md7.3 KiB
- references/operations/job-diagnostics.md17.7 KiB
- references/operations/jobinsight-api.md7.2 KiB
- references/operations/performance-patterns.md17.4 KiB
- references/operations/pipeline-diagnosis.md20.8 KiB
- references/operations/session-health.md8.7 KiB
- references/operations/spark-history-server.md6.5 KiB
references/mlv.md
<!-- Mode reference for the `spark-cli` skill. Loaded on demand from `skills/spark-cli/SKILL.md` when the request matches the `mlv` mode. -->
MLV Operations — CLI Skill
Terminology Mapping
Fabric has three materialized view concepts. Disambiguate by context:
| User context | User says | Actually means | Route to |
|---|---|---|---|
| Spark / Lakehouse | "materialized view" | Materialized Lake View (MLV) | This skill (the mlv mode) |
| Spark / Lakehouse | "materialized lake view" | MLV | This skill |
| Spark / Lakehouse | "spark materialized view" | MLV | This skill |
| Spark / Lakehouse | "MV" or "MLV" | MLV | This skill |
| Spark / Lakehouse | "CREATE MATERIALIZED LAKE VIEW" | MLV DDL (authoring) | the authoring mode |
| Spark / Lakehouse | "schedule my materialized view" | MLV scheduling | This skill |
| Spark / Lakehouse | "refresh my views" | MLV on-demand refresh | This skill |
| KQL / Eventhouse | "materialized view" | KQL Materialized View | eventhouse-cli |
| SQL DW / Warehouse | "materialized view" | Not supported in Fabric | Explain unsupported |
Disambiguation rule: If the user mentions lakehouse, notebook, Spark, Delta, or MLV → it's a Materialized Lake View (this skill). If they mention KQL, Eventhouse, or Kusto → it's a KQL Materialized View (different skill). If they mention Warehouse or SQL DW → explain it's not supported.
Default: If context is unclear (no mention of lakehouse, Spark, KQL, or Warehouse), ask the user: "Are you working with a Lakehouse (Materialized Lake View) or an Eventhouse (KQL Materialized View)?" before proceeding.
Interactive recurring refresh (no API or CI/CD): Direct users to Lakehouse → Materialized lake views → Manage → Schedules. Do not substitute notebook, pipeline, or generic Refresh → Schedule refresh navigation.
Manage MLV refresh scheduling, execution definitions, and monitoring using Fabric REST APIs. This skill provides public API coverage (Preview) for scheduling, subset refresh configuration, and monitoring operations, enabling automation of MLV refresh workflows.
What This Skill Can Do
✅ Fully Supported (14 REST APIs)
Schedule Management (per lakehouse — refreshes entire MLV lineage by default)
Create refresh schedules (Cron interval, Daily, Weekly, Monthly)
List schedules for a lakehouse
Get schedule details by ID
Update existing schedules (change frequency, enabled state)
Delete schedules
Attach an
executionData.mlvExecutionDefinitionIdto refresh a subset of the lineage
Job Execution
Trigger on-demand refresh (immediate execution)
List job run history with filtering
Get job status and progress
Cancel running jobs
Attach an
executionData.mlvExecutionDefinitionIdto refresh a subset of the lineage on demand
MLV Execution Definitions
Create reusable execution definitions for selected MLVs, selected upstream lakehouses, refresh mode, and Spark environment
List execution definitions
Get execution definition details
Patch execution definitions (partial update; omitted fields retain existing values)
Delete execution definitions; linked schedules are removed by the API
Safety & UX
Human-in-the-loop confirmations before creating schedules or triggering refreshes
Step-by-step planning for complex multi-MLV operations
Iterative error handling with helpful suggestions
Preview schedule impact before execution
❌ Not Supported through REST APIs
REST MLV Discovery:
GET /materializedLakeViewsreturns 404; use Spark SQL discovery insteadVisual Lineage Inspection: Cannot fetch the portal dependency graph directly
Data Quality Metrics: Cannot retrieve DQ metrics (API returns 404)
Schema Verification: Cannot check if schemas are enabled (property missing)
Discovery fallback: Resolve the lakehouse, then run
SHOW MATERIALIZED LAKE VIEWS IN <schema> through a Lakehouse Livy session
(consumption mode) or Fabric notebook (authoring mode). Ask the user for MLV
names only when no Spark execution surface is available. Then encode the
selected MLV names and upstream lakehouses in an MLV execution definition.
Table of Contents
| Task | Reference | Notes |
|---|---|---|
| RULES — Read these first, follow them always | SKILL.md § Must | MUST read — 6 rules for this skill |
| Finding Workspaces and Items in Fabric | COMMON-CLI.md § Finding Workspaces and Items in Fabric | Mandatory — READ link first [needed for finding workspace id by its name or item id by its name, item type, and workspace id] |
| Fabric Topology & Key Concepts | COMMON-CORE.md § Fabric Topology & Key Concepts | |
| Environment URLs | COMMON-CORE.md § Environment URLs | |
| Authentication & Token Acquisition | COMMON-CORE.md § Authentication & Token Acquisition | Wrong audience = 401; read before any auth issue |
| Job Scheduling | COMMON-CLI.md § Job Scheduling | URL is /jobs/{jobType}/schedules; endDateTime required |
| Job Execution | COMMON-CLI.md § Job Execution | |
Fabric Control-Plane API via az rest | COMMON-CLI.md § Fabric Control-Plane API via az rest | Always pass --resource https://api.fabric.microsoft.com or az rest fails |
| Pagination Pattern | COMMON-CLI.md § Pagination Pattern | |
| Gotchas & Troubleshooting (CLI-Specific) | COMMON-CLI.md § Gotchas & Troubleshooting (CLI-Specific) | az rest audience, shell escaping, token expiry |
Quick Reference: az rest Template | COMMON-CLI.md § Quick Reference: az rest Template | |
| MLV Public API Reference | MS Learn: Manage Fabric materialized lake views with public APIs | Official documentation for schedules, on-demand refresh, job instances, and MLV execution definitions |
Eval mode: When the user prompt contains "I pre-approve" or "proceed without confirmation", skip the human-in-the-loop gate and execute directly. This allows automated testing.
Must
1. Human-in-the-loop confirmations
Before executing any operation, show a preview and ask for confirmation:
Creating schedules: Show schedule type, interval/times, lakehouse ID, start/end time, and full-lineage or execution-definition scope
Creating execution definitions: Show selected MLVs, selected upstream lakehouses, refresh mode, and Spark environment
Triggering refreshes: Show lakehouse ID and whether this refreshes the full lineage or a named execution definition subset
Deleting schedules: Show schedule ID and confirm deletion
Deleting execution definitions: Show definition ID and warn that linked schedules are also removed
Confirmation options:
Allow— Execute this single operationDecline— Skip this operationAllow in this thread— Auto-allow all operations in current conversation
Example:
I'm about to create a refresh schedule:
Lakehouse ID: abc-123-def
Type: Daily
Time: 02:00 UTC
Start: 2026-06-20
End: 2027-06-20
Scope: Full MLV lineage (default)
Proceed? [Allow / Decline / Allow in this thread]2. Use REST APIs exactly as documented
Base URL: https://api.fabric.microsoft.com/v1
Deterministic PowerShell execution:
Workspace list objects use
displayName, notname. List once, filterdisplayNameby exact equality, and require exactly one match instead of retrying alternate fields or filters.For every non-empty JSON body, serialize once, write it with
[IO.File]::WriteAllText($path, $json, [Text.UTF8Encoding]::new($false)), then pass--headers "Content-Type=application/json"and--body "@$path"toaz rest. Do not pass inline JSON or a JSON variable on Windows.Submit each mutation once. Treat a 4xx response with
isRetriable: falseas final: report it and do not retry the POST with another encoding.
IMPORTANT: Schedule, on-demand trigger, execution-definition, and history-list endpoints are workspace + lakehouse scoped. An on-demand trigger returns an item-scoped Location URL for status polling and cancellation. A schedule or on-demand run refreshes the entire MLV lineage by default. To refresh selected MLVs or selected upstream lakehouses, create an MLV execution definition and pass its mlvExecutionDefinitionId in executionData.
Schedule endpoints:
POST /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules— Create scheduleGET /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules— List schedulesGET /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules/{id}— Get schedulePATCH /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules/{id}— Update scheduleDELETE /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules/{id}— Delete schedule
Job instance endpoints:
POST /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/instances— Trigger on-demand refresh (optionalexecutionData; returns 202 + Location header with job ID)GET /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/instances— List job historyGET /workspaces/{workspaceId}/items/{lakehouseId}/jobs/instances/{jobInstanceId}— Get job status from the triggerLocationPOST /workspaces/{workspaceId}/items/{lakehouseId}/jobs/instances/{jobInstanceId}/cancel— Cancel the running job
MLV execution definition endpoints:
POST /workspaces/{workspaceId}/lakehouses/{lakehouseId}/mlvexecutiondefinitions— Create selected-lineage execution definitionGET /workspaces/{workspaceId}/lakehouses/{lakehouseId}/mlvexecutiondefinitions— List execution definitionsGET /workspaces/{workspaceId}/lakehouses/{lakehouseId}/mlvexecutiondefinitions/{mlvExecutionDefinitionId}— Get execution definitionPATCH /workspaces/{workspaceId}/lakehouses/{lakehouseId}/mlvexecutiondefinitions/{mlvExecutionDefinitionId}— Partially update execution definitionDELETE /workspaces/{workspaceId}/lakehouses/{lakehouseId}/mlvexecutiondefinitions/{mlvExecutionDefinitionId}— Delete execution definition and any linked schedules
Job type mismatch trap: Job history can expose scheduled MLV runs as jobType: "MaterializedLakeViews", but the public job scheduler path uses refreshMaterializedLakeViews. Do not copy the history value into POST /workspaces/{workspaceId}/items/{lakehouseId}/jobs/instances?jobType=MaterializedLakeViews; that item-level call returns InvalidJobType.
See: MS Learn: MLV Background Jobs
3. Authentication
All scheduling operations (create/update/delete, trigger, status, cancel) support both User identity (az login) and Service Principal / Managed Identity. Requires Workspace Contributor or Admin role.
4. Lakehouse schedule limits and execution-definition scopes
The Preview REST scheduler supports refresh schedules at lakehouse scope. A lakehouse can have at most 20 schedules, and an MLV lineage can have only one active refresh schedule. If the user asks for a subset schedule, create an MLV execution definition with selected MLVs/upstream lakehouses and pass its mlvExecutionDefinitionId in schedule or on-demand executionData. Execution definitions scope a refresh; they don't bypass scheduler limits.
5. MLV discovery through Spark SQL
GET /materializedLakeViews returns 404, but that REST limitation does not make
discovery impossible. Resolve the lakehouse and run:
SHOW MATERIALIZED LAKE VIEWS IN <schema>;Execute it through a Lakehouse Livy session (consumption mode) or notebook
cell (authoring mode). See
Materialized Lake View Patterns — SQL management commands.
Ask the user for MLV names only when a Spark session is unavailable.
6. Run History diagnostic workflow
When a user asks "why did my refresh fail?" or "show me run history", follow this sequence:
List recent runs:
GET /instances— returns job instances with status, start/end timesShow run summary: Display table with run ID, status, start/end time, duration
Select failed run: If multiple, ask user which one to investigate
Read error code: Extract
failureReason.errorCodeandfailureReason.messagefrom the failed instanceSuggest next steps: Based on error code:
MLV_SPARK_SESSION_REQUEST_SUBMISSION_FAILED→ Check capacity availability, Spark pool configMLV_SELECTED_NOT_FOUND→ MLV table was deleted or renamed, verify it existsOther Spark errors → Route to
theoperationsmodefor OOM, skew, shuffle spill diagnosis
Per-view details: The API returns lineage-level status only. Per-view status (which individual MLVs failed) is available in the UI Recent runs page — direct the user there for view-level breakdown
Run statuses (from API): NotStarted, InProgress, Completed, Failed, Cancelled, Deduped
Note: Run history retention may be limited. If older runs are missing, check the Recent runs page in the Lakehouse UI.
Prefer
Daily/Weekly types for precise time-of-day scheduling (e.g., "2 AM daily")
Cron type with interval only for sub-daily frequencies (e.g., "every 60 minutes")
Step-by-step planning — clarify intent, propose schedule, show preview, execute on approval
Iterative error handling — on failure, explain what went wrong and suggest actionable fixes
Explicit timezone in every schedule (
localTimeZoneId)Cross-lakehouse scheduling from extended lineage — when MLVs span multiple lakehouses, schedule from the downstream lakehouse's lineage view. Extended lineage refreshes upstream dependencies automatically in dependency order. Prefer this over creating separate schedules on each lakehouse individually.
Avoid
Per-table scheduling claims without an execution definition — full-lineage is the default; selected subsets require a saved execution definition
Cron string expressions (e.g.,
0 2 * * *) — the API uses structured types, not cron stringsAssuming JSON response from on-demand refresh — returns 202 with job ID in Location header only
Silent failures — always explain errors
Scheduling from notebooks or pipelines — recurring MLV refresh belongs to Lakehouse schedules. SQL
REFRESH ... FULLis for one-time manual troubleshooting only.
Schedule Payload Structure
Create Schedule (POST /schedules)
Endpoint: POST /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules
{
"enabled": true,
"configuration": {
"type": "Cron",
"interval": 60,
"startDateTime": "2026-06-20T00:00:00",
"endDateTime": "2027-06-20T23:59:59",
"localTimeZoneId": "UTC"
}
}Subset lineage schedule: include executionData when the user wants to refresh only the MLVs/upstream lakehouses captured in an execution definition:
{
"enabled": true,
"configuration": {
"type": "Cron",
"interval": 60,
"startDateTime": "2026-06-20T00:00:00",
"endDateTime": "2027-06-20T23:59:59",
"localTimeZoneId": "UTC"
},
"executionData": {
"mlvExecutionDefinitionId": "<mlvExecutionDefinitionId>"
}
}Key fields:
enabled:trueto enable schedule on creationtype: One of"Cron","Daily","Weekly","Monthly"interval: (Cron only) Refresh interval in minutes (e.g.,60= hourly,120= every 2 hours)times: (Daily/Weekly/Monthly) Array of times in"HH:MM"format, e.g.,["02:00"]weekdays: (Weekly only) e.g.,["Monday", "Wednesday", "Friday"]— PascalCase day namesrecurrence: (Monthly only) Recurrence interval, e.g.,1(every month)occurrence: (Monthly only) e.g.,{"occurrenceType": "DayOfMonth", "dayOfMonth": 1}localTimeZoneId: Windows time zone names —"UTC","Central Standard Time","India Standard Time", etc.startDateTime: When schedule becomes active (ISO 8601 local time;localTimeZoneIdsupplies the time zone)endDateTime: REQUIRED — When schedule expiresexecutionData.mlvExecutionDefinitionId: Optional; refreshes only the selected lineage captured in that execution definition
Daily example (preferred for "2 AM every day"):
{ "enabled": true, "configuration": { "type": "Daily", "times": ["02:00"], "startDateTime": "2026-06-20T00:00:00", "endDateTime": "2027-06-20T23:59:59", "localTimeZoneId": "UTC" } }Weekly example (weekdays at 6 AM):
{ "enabled": true, "configuration": { "type": "Weekly", "times": ["06:00"], "weekdays": ["Monday", "Friday"], "startDateTime": "2026-06-20T00:00:00", "endDateTime": "2027-06-20T23:59:59", "localTimeZoneId": "UTC" } }Monthly example (1st of each month at midnight):
{ "enabled": true, "configuration": { "type": "Monthly", "recurrence": 1, "occurrence": {"occurrenceType": "DayOfMonth", "dayOfMonth": 1}, "times": ["00:00"], "startDateTime": "2026-06-20T00:00:00", "endDateTime": "2027-06-20T23:59:59", "localTimeZoneId": "UTC" } }WARNING: Do NOT use
"days": [1, 15]for Monthly — this returns400 InvalidConfiguration. Userecurrence+occurrenceas shown above.
Update Schedule (PATCH /schedules/{id})
Endpoint: PATCH /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/schedules/{id}
{
"enabled": true,
"configuration": {
"type": "Cron",
"interval": 120,
"startDateTime": "2026-06-20T00:00:00",
"endDateTime": "2027-06-20T23:59:59",
"localTimeZoneId": "UTC"
}
}Note: The update API requires both enabled and a complete configuration (full replacement, not partial patch). Always send all fields.
MLV Execution Definitions
Use execution definitions when the user wants to refresh specific MLVs, include selected upstream lakehouses, pin a Spark environment, or choose a refresh mode independently from the default full-lineage refresh.
Create MLV Execution Definition
Endpoint: POST /workspaces/{workspaceId}/lakehouses/{lakehouseId}/mlvexecutiondefinitions
{
"displayName": "Gold Chain - Sales",
"description": "Nightly refresh for selected gold-layer MLVs",
"settings": {
"environment": {
"referenceType": "ById",
"itemId": "<environmentId>",
"workspaceId": "<environmentWorkspaceId>"
},
"refreshMode": "Optimal"
},
"currentLakehouseExecutionContext": {
"mode": "Selected",
"selectedMlvs": [
"dbo.gold_sales_summary",
"dbo.gold_sales_daily"
]
},
"extendedLineageExecutionContext": {
"mode": "All"
}
}Execution context modes:
currentLakehouseExecutionContext.mode:"All"or"Selected"; when"Selected", provideselectedMlvsas fully qualified MLV names.extendedLineageExecutionContext.mode:"All"or"Selected"; when"Selected", provideselectedLakehousesobjects withreferenceType,itemId, andworkspaceId.settings.refreshMode:"Optimal"or"Full".settings.environment: Optional Spark environment reference by ID.
Update semantics: PATCH /mlvexecutiondefinitions/{id} is a partial update. Only provided fields change; omitted fields retain their existing values. This differs from schedule PATCH, which requires enabled and a complete configuration.
Delete semantics: DELETE /mlvexecutiondefinitions/{id} also removes schedules linked to that execution definition. Warn before deleting.
Trigger On-Demand Refresh (POST /instances)
Endpoint: POST /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/instances
Request body: None for full-lineage refresh. Refreshes the entire MLV lineage in dependency order.
Subset refresh body:
{
"executionData": {
"mlvExecutionDefinitionId": "<mlvExecutionDefinitionId>"
}
}Do not use job history as the trigger contract: recent runs may list jobType: "MaterializedLakeViews", but that value is only a history/status label. For on-demand refresh, always call this lakehouse-scoped endpoint. Reusing the history label with the generic item job API (POST /workspaces/{workspaceId}/items/{lakehouseId}/jobs/instances?jobType=MaterializedLakeViews) is a known InvalidJobType dead end.
The trigger response returns an item-scoped Location URL (/items/{lakehouseId}/jobs/instances/{jobInstanceId}). Use it as-is for polling and cancellation. The lakehouse-scoped GET (/lakehouses/{lakehouseId}/jobs/instances/{jobInstanceId}) is documented as an alternative and returns the same instance, but the service does not return that shape in the Location header today.
Response: 202 Accepted — job instance ID is in the Location response header:
Location: https://api.fabric.microsoft.com/v1/workspaces/{wsId}/items/{lakehouseId}/jobs/instances/{jobInstanceId}
Retry-After: 60Poll for status using the URL from the Location header (or its lakehouse-scoped equivalent):
GET /workspaces/{workspaceId}/items/{lakehouseId}/jobs/instances/{jobInstanceId}Job instance status values:
| Status | Meaning |
|---|---|
NotStarted | Job is queued but hasn't begun |
InProgress | Job is actively running |
Completed | Job finished successfully |
Failed | Job failed (check failureReason) |
Cancelled | Job was cancelled by user |
Deduped | Skipped because another refresh was already in progress |
Note: Job instances returned by public GET /lakehouses/{id}/jobs/refreshMaterializedLakeViews/instances use jobType: "RefreshMaterializedLakeViews" per MS Learn. Some item-level history surfaces have returned jobType: "MaterializedLakeViews" in live testing; filter on either value when diagnosing legacy history, but never use MaterializedLakeViews as an on-demand trigger jobType.
Status display limitation: job instance status reflects Monitor hub status and can differ from the MLV run-history UI. For example, an MLV run-history Skipped status can appear as Cancelled/Canceled in Monitor hub APIs.
Schedule settings (additional options via UI or API):
Optimal Refresh (default: On) — Fabric picks incremental or full refresh per MLV automatically
Extended lineage — refreshes chains across multiple lakehouses in dependency order from a single schedule
Example Workflows
Workflow 1: Schedule Nightly Refresh
User prompt: "Schedule sales_monthly MLV in CustomerVoice lakehouse to refresh at 2 AM daily"
Agent steps:
Find workspace ID for "CustomerVoice" via
GET /workspaces+ JMESPathFind lakehouse ID via
GET /workspaces/{id}/lakehouses+ JMESPathClarify scope: "Do you want the default full-lineage schedule, or should I create an MLV execution definition for only
sales_monthly?"If the user chooses subset scope, create an execution definition with
currentLakehouseExecutionContext.mode = "Selected"andselectedMlvs = ["dbo.sales_monthly"](or the user's actual fully qualified MLV name), then include itsmlvExecutionDefinitionIdin scheduleexecutionData.Show preview:
Creating schedule: Lakehouse: CustomerVoice (ID: xyz-456-ghi) Scope: Full lineage OR execution definition <id> Type: Daily, Time: 02:00 UTC Start: Now End: 1 year from now Proceed? [Allow / Decline]On "Allow": POST schedule payload, return schedule ID
Report: "Schedule created (ID: sched-789). Scope: full lineage OR execution definition <id>."
Workflow 2: Trigger Immediate Refresh
User prompt: "Refresh inventory_daily MLV now in lakehouse xyz-456-ghi"
Agent steps:
Confirm lakehouse ID is valid (GET /lakehouses/{id})
Clarify scope and show preview:
Triggering on-demand refresh: Lakehouse ID: xyz-456-ghi Scope: Full lineage OR execution definition <id> Do you want the default full-lineage refresh, or only `inventory_daily` through an execution definition? Proceed? [Allow / Decline]If the user chooses a subset, create or reuse an execution definition for
inventory_dailyand send its ID inexecutionData; otherwise POST/instanceswith no body. Capture the job ID from the Location header.Poll using the item-scoped URL returned in the
Locationheader, or its documented lakehouse-scoped equivalentGET /workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/instances/{jobId}, and show progress.Report: "✅ Refresh completed in 2m 34s" or "❌ Refresh failed: [error message]"
Workflow 3: User Asks for Per-MLV Scheduling (Explain Limitation)
User prompt: "Schedule bronze_sales, silver_sales, gold_sales to refresh at 2 AM, 3 AM, 4 AM respectively"
Agent steps:
Explain limitation:
These views are a dependency chain, so schedule them as one lineage refresh rather than at separate times. Lakehouse scheduling refreshes dependencies in the required order. Options: 1. Single Daily schedule at 2 AM (refreshes all 3 in order) 2. If the MLVs are independent, create separate execution definitions and schedules within the lakehouse's 20-schedule limit 3. If they're in separate lakehouses, create one schedule per lakehouse Which would you prefer?If user picks option 1: Create one Daily schedule with
"times": ["02:00"]If user picks option 2: Confirm the MLVs are independent, then create the execution definitions and schedules
If user picks option 3: Confirm lakehouse IDs for each, then create schedules
Workflow 4: List and Delete Schedules
User prompt: "Show my schedule and delete it if it's outdated"
Agent steps:
Ask user for workspace and lakehouse (cannot list schedules globally)
GET /workspaces/{wsId}/lakehouses/{lhId}/jobs/refreshMaterializedLakeViews/schedulesParse response (usually 1 schedule per lineage), show details:
Active schedule on lakehouse 'CustomerVoice': - ID: sched-111 (created 2025-10-15, type: Daily, time: 02:00) Delete this schedule? [Allow / Decline]On "Allow": DELETE /schedules/{id}, confirm
Report: "✅ Schedule deleted"
Common Errors & Fixes
Error: 400 Bad Request — Invalid Interval
Message: "The interval '0' is invalid. Interval must be between 1 and 5270400 (10 years in minutes)."
Fix:
Interval must be a valid number of minutes between 1 and 5,270,400 (10 years).
Common intervals:
60 = hourly
1440 = daily (24 hours)
10080 = weekly (7 days)
Would you like me to adjust the interval to a valid value?Error: 409 Conflict — Schedule Already Exists
Message: "A schedule already exists for this lakehouse"
Fix:
A schedule is already active for this lakehouse. Options:
1. Update existing schedule (change interval/time)
2. Delete and recreate (replaces schedule)
3. Leave as-is (no change)
Which would you prefer?Error: 404 Not Found — Lakehouse ID Invalid
Message: "Lakehouse 'wrong-id-123' not found in workspace 'abc-456'"
Fix:
The lakehouse ID you provided doesn't exist. Let me list available lakehouses:
[Call GET /workspaces/{id}/lakehouses, show table]
Which lakehouse should I use?Error: 403 Forbidden — Permission Denied
Message: "User does not have permission to create schedules in this workspace"
Fix:
You need Workspace Contributor or Admin role to create schedules.
Current permissions: Viewer (read-only)
Required: Contributor or Admin
Contact your workspace admin to request elevated permissions.Tips for Users
1. Find Your Lakehouse ID
Option A: Via REST API
az rest --resource https://api.fabric.microsoft.com \
--url "https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses" \
--method GETExtract id from the response for your lakehouse.
Option B: Via Fabric UI
Open lakehouse in Fabric portal
Click Settings (gear icon)
Copy "Lakehouse ID" from properties
2. Common Schedule Configurations
| Need | Type | Key field |
|---|---|---|
| Every hour | Cron | "interval": 60 |
| Daily at 2 AM | Daily | "times": ["02:00"] |
| Weekdays at 6 AM | Weekly | "times": ["06:00"], "weekdays": ["Monday","Friday"] |
| 1st of each month | Monthly | "recurrence": 1, "occurrence": {"occurrenceType": "DayOfMonth", "dayOfMonth": 1} |
3. Monitor Job History
List recent refresh jobs (authenticate per COMMON-CLI.md § Quick Reference: az rest Template):
# See COMMON-CLI.md for authentication setup
az rest --resource https://api.fabric.microsoft.com \
--url "https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId}/jobs/refreshMaterializedLakeViews/instances" \
--method GETNote: The list instances API does not support OData query parameters (
$top,$orderby,$filter). Sort and filter results client-side after retrieval. UsecontinuationTokenfor pagination.
4. Time Zone Considerations
Default: Schedules use UTC unless specified.
Best practice: Always specify timezone explicitly to avoid confusion:
{
"configuration": {
"localTimeZoneId": "Central Standard Time"
}
}Valid time zones: Windows time zone names (e.g., "Central Standard Time", "Pacific Standard Time", "India Standard Time"). Use the Windows Default Time Zones registry.
Related Skills
the
authoringmode: Create MLVs in Fabric Notebooks (authoring side)
Limitations & Future Roadmap
Current Limitations (as of 2026-06-18)
| Feature | Status | Workaround |
|---|---|---|
| List MLVs through REST | ❌ API returns 404 | Run SHOW MATERIALIZED LAKE VIEWS IN <schema> through Livy or a notebook; ask for names only if Spark execution is unavailable |
| Refresh selected MLVs / subset lineage | ✅ Use MLV execution definitions | Create /mlvexecutiondefinitions, then pass executionData.mlvExecutionDefinitionId |
| Get visual lineage graph | ❌ No public graph API | Use Fabric Lakehouse UI |
| Check data quality metrics | ❌ API returns 404 | Use Fabric Lakehouse UI |
| Verify schema support | ❌ Property missing | Assume schemas enabled if MLVs work |
What Works Today (public MLV API coverage (Preview))
✅ Create/list/update/delete schedules (5 APIs)
✅ Trigger/monitor/cancel refresh jobs (4 APIs)
✅ Create/list/get/update/delete MLV execution definitions (5 APIs)
✅ Full-lineage or selected-lineage refresh via
executionData.mlvExecutionDefinitionId✅ Full automation of refresh workflows
✅ Human-in-the-loop safety confirmations
✅ Iterative error handling
Planned (When REST APIs Ship)
REST MLV Discovery: Auto-list MLVs without a Spark session
Visual Lineage Tracing: Show dependency graphs
Data Quality: Fetch DQ metrics programmatically
Schema Verification: Check
enableSchemasproperty
Agent design is forward-compatible: When APIs become available, add discovery capabilities without changing scheduling logic.
Conclusion
This skill provides validated automation for MLV refresh scheduling, execution definitions, and monitoring using public REST APIs. While MLV discovery and visual lineage inspection still require UI workarounds today, scheduling, selected-lineage execution definitions, and job execution work as documented.
Design philosophy (inspired by Databricks Data Engineering Agent):
Human-in-the-loop confirmations for safety
Step-by-step planning for complex tasks
Iterative error handling with helpful suggestions
Transparent about limitations (no speculative workarounds)
Next steps: Use this skill to automate MLV refresh workflows. When discovery APIs ship, we'll extend the skill to eliminate manual lakehouse ID + table name input.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills-for-fabric · skills/spark-cli · commit f8fac11
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- microsoft/skills-for-fabric
AutoGineer is not affiliated with or endorsed by Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download spark-cli.zip