Telemetry — MANDATORY. Every api.fabric.microsoft.com call must carry
x-ms-fabric-skill: spark-consumption-cli (az rest: --headers "x-ms-fabric-skill=spark-consumption-cli"),
including every LRO poll, fabric_lro and retry. Snippets omit it — add it anyway.
Update Check — ONCE PER SESSION (mandatory)
The first time this skill is used in a session, run the check-updates skill before proceeding.
- GitHub Copilot CLI / VS Code: invoke the
check-updates skill.
- Claude Code / Cowork / Cursor / Windsurf / Codex: compare local vs remote package.json version.
- Skip if the check was already performed earlier in this session.
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
Data Engineering Consumption — CLI Skill
Table of Contents
| Task |
Reference |
Notes |
| 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 |
| Core Control-Plane REST APIs |
COMMON-CORE.md § Core Control-Plane REST APIs |
|
| Pagination |
COMMON-CORE.md § Pagination |
|
| Long-Running Operations (LRO) |
COMMON-CORE.md § Long-Running Operations (LRO) |
|
| Rate Limiting & Throttling |
COMMON-CORE.md § Rate Limiting & Throttling |
|
| OneLake Data Access |
COMMON-CORE.md § OneLake Data Access |
Requires storage.azure.com token, not Fabric token |
| Job Execution |
COMMON-CORE.md § Job Execution |
|
| Capacity Management |
COMMON-CORE.md § Capacity Management |
|
| Gotchas & Troubleshooting |
COMMON-CORE.md § Gotchas & Troubleshooting |
|
| Best Practices |
COMMON-CORE.md § Best Practices |
|
| Tool Selection Rationale |
COMMON-CLI.md § Tool Selection Rationale |
|
| 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] |
| Authentication Recipes |
COMMON-CLI.md § Authentication Recipes |
az login flows and token acquisition |
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 |
|
| Long-Running Operations (LRO) Pattern |
COMMON-CLI.md § Long-Running Operations (LRO) Pattern |
|
OneLake Data Access via curl |
COMMON-CLI.md § OneLake Data Access via curl |
Use curl not az rest (different token audience) |
| SQL / TDS Data-Plane Access |
COMMON-CLI.md § SQL / TDS Data-Plane Access |
sqlcmd (Go) connect, query, CSV export |
| Job Execution (CLI) |
COMMON-CLI.md § Job Execution |
|
| OneLake Shortcuts |
COMMON-CLI.md § OneLake Shortcuts |
|
| Capacity Management (CLI) |
COMMON-CLI.md § Capacity Management |
|
| Composite Recipes |
COMMON-CLI.md § Composite Recipes |
|
| 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 |
|
| Quick Reference: Token Audience / CLI Tool Matrix |
COMMON-CLI.md § Quick Reference: Token Audience ↔ CLI Tool Matrix |
Which --resource + tool for each service |
| Relationship to SPARK-AUTHORING-CORE.md |
SPARK-CONSUMPTION-CORE.md § Relationship to SPARK-AUTHORING-CORE.md |
|
| Data Engineering Consumption Capability Matrix |
SPARK-CONSUMPTION-CORE.md § Data Engineering Consumption Capability Matrix |
|
| OneLake Table APIs (Schema-enabled Lakehouses) |
SPARK-CONSUMPTION-CORE.md § OneLake Table APIs (Schema-enabled Lakehouses) |
Unity Catalog-compatible metadata; requires storage.azure.com token |
| Lakehouse Livy Session Management |
SPARK-CONSUMPTION-CORE.md § Livy Session Management |
Lakehouse Livy API: session creation, states, lifecycle, termination |
| Interactive Data Exploration |
SPARK-CONSUMPTION-CORE.md § Interactive Data Exploration |
Statement execution, output retrieval, data discovery |
| PySpark Analytics Patterns |
SPARK-CONSUMPTION-CORE.md § PySpark Analytics Patterns |
Cross-lakehouse 3-part naming, performance optimization |
| Must/Prefer/Avoid |
SKILL.md § Must/Prefer/Avoid |
MUST DO / AVOID / PREFER checklists |
| Quick Start |
SKILL.md § Quick Start |
CLI-specific Lakehouse Livy session setup and data exploration |
| Key Fabric Patterns |
SKILL.md § Key Fabric Patterns |
Spark pattern quick-reference table |
| Session Cleanup |
SKILL.md § Session Cleanup |
Clean up idle Lakehouse Livy sessions via CLI |
Must/Prefer/Avoid
MUST DO
- Check for existing idle sessions before creating new ones
- Use dynamic workspace/lakehouse discovery
- Follow API patterns from COMMON-CLI.md
PREFER
- sqldw-consumption-cli for simple lakehouse queries — row counts, SELECT, schema exploration, filtering, and aggregation on lakehouse Delta tables should use the SQL Endpoint via
sqlcmd, not Spark. Only use this skill when the user explicitly requests PySpark, DataFrames, or Spark-specific features.
- SQL Endpoint for Delta tables
- Livy for unstructured/JSON data or complex Python analytics
- Session reuse over creation
AVOID
- Hardcoded workspace IDs
- Creating unnecessary sessions
- Large result sets without LIMIT
- Confusing Lakehouse Livy sessions with Notebook Spark sessions — This skill covers Lakehouse Livy sessions (the public Livy API at
/lakehouses/{lhId}/livyapi/.../sessions). Notebook Spark sessions are created internally when running a notebook via the Jobs API (RunNotebook) and are NOT managed through the Livy API. To run a notebook as a job, see SPARK-AUTHORING-CORE.md § Notebook Execution & Job Management
- Writing or generating notebook cells — prompts that ask for
%%sql, %%configure, PySpark notebook cell code, notebook deployment, or notebook execution belong to spark-authoring-cli, even when the cell queries data.
Quick Start
Environment Setup
Apply environment detection from COMMON-CORE.md Environment Detection Pattern to set:
$FABRIC_API_BASE and $FABRIC_RESOURCE_SCOPE
$FABRIC_API_URL and $LIVY_API_PATH for Livy operations
Authentication: Use token acquisition from COMMON-CLI.md Environment Detection and API Configuration
Workspace & Item Discovery
Preferred: Use COMMON-CLI.md item discovery patterns (Finding things in Fabric) to find workspaces and items by name.
Fallback (when workspace is already known):
# List workspaces
az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces" --query "value[].{name:displayName, id:id}" --output table
read -p "Workspace ID: " workspaceId
# List lakehouses in workspace
az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/items?type=Lakehouse" --query "value[].{name:displayName, id:id}" --output table
read -p "Lakehouse ID: " lakehouseId
Lakehouse Livy Session Management
Two types of Spark sessions in Fabric — This skill manages Lakehouse Livy sessions, created via the public Livy API endpoint (/lakehouses/{lhId}/livyapi/.../sessions). These are ad-hoc interactive sessions for remote clients. Notebook Spark sessions are a separate mechanism — they are created internally when a Fabric Notebook is executed (via portal or Jobs API RunNotebook), and are managed through the notebook lifecycle, not the Livy API.
# Check for existing idle Lakehouse Livy session (avoid resource waste)
sessionId=$(az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions" --query "sessions[?state=='idle'][0].id" --output tsv)
# Create if none available - FORCE STARTER POOL USAGE
if [[ -z "$sessionId" ]]; then
cat > /tmp/body.json << 'EOF'
{
"name":"analysis",
"driverMemory":"56g",
"driverCores":8,
"executorMemory":"56g",
"executorCores":8,
"conf": {
"spark.dynamicAllocation.enabled": "true",
"spark.fabric.pool.name": "Starter Pool"
}
}
EOF
sessionId=$(az rest --method post --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions" --body @/tmp/body.json --query "id" --output tsv)
echo "⏳ Waiting for starter pool session to be ready..."
# With starter pools, this should be 3-5 seconds
timeout=30 # Reduced from 90s since starter pools are fast
while [ $timeout -gt 0 ]; do
state=$(az rest --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions/$sessionId" --query "state" --output tsv)
if [[ "$state" == "idle" ]]; then
echo "✅ Session ready in starter pool!"
break
fi
echo " Session state: $state (${timeout}s remaining)"
sleep 3
timeout=$((timeout - 3))
done
fi
Data Exploration (Fabric-Specific Patterns)
# Execute statement (LLM knows Python/Spark syntax)
cat > /tmp/body.json << 'EOF'
{
"code": "spark.sql(\"SHOW TABLES\").show(); df = spark.table(\"your_table\"); df.describe().show()",
"kind": "pyspark"
}
EOF
az rest --method post --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions/$sessionId/statements" --body @/tmp/body.json
Key Fabric Patterns
| Pattern |
Code |
Use Case |
| Table Discovery |
spark.sql("SHOW TABLES") |
List available tables |
| Cross-Lakehouse |
spark.sql("SELECT * FROM other_workspace.table") |
Query across workspaces |
| Delta Features |
df.history(), df.readVersion(1) |
Time travel, versioning |
| Schema Evolution |
df.printSchema() |
Understand structure |
Lakehouse Livy Session Cleanup
# Clean up idle Lakehouse Livy sessions (optional)
az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions" --query "sessions[?state=='idle'].id" --output tsv | xargs -I {} az rest --method delete --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions/{}"
Focus: This skill provides Fabric-specific REST API patterns. LLM already knows Python/Spark syntax — we focus on Fabric integration, session management, and API endpoints.
1---2name: spark-consumption-cli3description: Interactive ad-hoc Spark analysis through Fabric Lakehouse Livy API sessions ONLY. This skill NEVER authors or runs a notebook: any notebook cell (%%sql/%%configure) or a notebook-run-by-name (and reporting its run status) is `spark-authoring-cli`, not this skill. Scope: create a Livy session, execute PySpark, inspect output, and compute quick calculations over lakehouse data (DataFrames, cross-lakehouse joins, Delta time-travel, unstructured/JSON). For Spark failure triage use `spark-operations-cli`; for plain T-SQL Lakehouse/Warehouse queries use `sqldw-consumption-cli`. Triggers: "create Livy session", "run Livy calculation", "Livy session calculation", "interactive Livy session", "PySpark", "analyze with PySpark", "Spark DataFrame", "lakehouse with Python", "PySpark data quality", "Delta time-travel with Spark", "join tables across Lakehouses".4---56> **Telemetry — MANDATORY.** Every `api.fabric.microsoft.com` call must carry7> `x-ms-fabric-skill: spark-consumption-cli` (`az rest`: `--headers "x-ms-fabric-skill=spark-consumption-cli"`),8> including every LRO poll, `fabric_lro` and retry. Snippets omit it — add it anyway.910> **Update Check — ONCE PER SESSION (mandatory)**11> The first time this skill is used in a session, run the **check-updates** skill before proceeding.12> - **GitHub Copilot CLI / VS Code**: invoke the `check-updates` skill.13> - **Claude Code / Cowork / Cursor / Windsurf / Codex**: compare local vs remote package.json version.14> - Skip if the check was already performed earlier in this session.1516> **CRITICAL NOTES**17> 1. To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering18> 2. 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 filtering1920# Data Engineering Consumption — CLI Skill2122## Table of Contents2324| Task | Reference | Notes |25|---|---|---|26| Fabric Topology & Key Concepts | [COMMON-CORE.md § Fabric Topology & Key Concepts](../../common/COMMON-CORE.md#fabric-topology--key-concepts) ||27| Environment URLs | [COMMON-CORE.md § Environment URLs](../../common/COMMON-CORE.md#environment-urls) ||28| Authentication & Token Acquisition | [COMMON-CORE.md § Authentication & Token Acquisition](../../common/COMMON-CORE.md#authentication--token-acquisition) | Wrong audience = 401; read before any auth issue |29| Core Control-Plane REST APIs | [COMMON-CORE.md § Core Control-Plane REST APIs](../../common/COMMON-CORE.md#core-control-plane-rest-apis) ||30| Pagination | [COMMON-CORE.md § Pagination](../../common/COMMON-CORE.md#pagination) ||31| Long-Running Operations (LRO) | [COMMON-CORE.md § Long-Running Operations (LRO)](../../common/COMMON-CORE.md#long-running-operations-lro) ||32| Rate Limiting & Throttling | [COMMON-CORE.md § Rate Limiting & Throttling](../../common/COMMON-CORE.md#rate-limiting--throttling) ||33| OneLake Data Access | [COMMON-CORE.md § OneLake Data Access](../../common/COMMON-CORE.md#onelake-data-access) | Requires `storage.azure.com` token, not Fabric token |34| Job Execution | [COMMON-CORE.md § Job Execution](../../common/COMMON-CORE.md#job-execution) ||35| Capacity Management | [COMMON-CORE.md § Capacity Management](../../common/COMMON-CORE.md#capacity-management) ||36| Gotchas & Troubleshooting | [COMMON-CORE.md § Gotchas & Troubleshooting](../../common/COMMON-CORE.md#gotchas--troubleshooting) ||37| Best Practices | [COMMON-CORE.md § Best Practices](../../common/COMMON-CORE.md#best-practices) ||38| Tool Selection Rationale | [COMMON-CLI.md § Tool Selection Rationale](../../common/COMMON-CLI.md#tool-selection-rationale) ||39| Finding Workspaces and Items in Fabric | [COMMON-CLI.md § Finding Workspaces and Items in Fabric](../../common/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] |40| Authentication Recipes | [COMMON-CLI.md § Authentication Recipes](../../common/COMMON-CLI.md#authentication-recipes) | `az login` flows and token acquisition |41| Fabric Control-Plane API via `az rest` | [COMMON-CLI.md § Fabric Control-Plane API via az rest](../../common/COMMON-CLI.md#fabric-control-plane-api-via-az-rest) | **Always pass `--resource https://api.fabric.microsoft.com`** or `az rest` fails |42| Pagination Pattern | [COMMON-CLI.md § Pagination Pattern](../../common/COMMON-CLI.md#pagination-pattern) ||43| Long-Running Operations (LRO) Pattern | [COMMON-CLI.md § Long-Running Operations (LRO) Pattern](../../common/COMMON-CLI.md#long-running-operations-lro-pattern) ||44| OneLake Data Access via `curl` | [COMMON-CLI.md § OneLake Data Access via curl](../../common/COMMON-CLI.md#onelake-data-access-via-curl) | Use `curl` not `az rest` (different token audience) |45| SQL / TDS Data-Plane Access | [COMMON-CLI.md § SQL / TDS Data-Plane Access](../../common/COMMON-CLI.md#sql--tds-data-plane-access) | `sqlcmd` (Go) connect, query, CSV export |46| Job Execution (CLI) | [COMMON-CLI.md § Job Execution](../../common/COMMON-CLI.md#job-execution) ||47| OneLake Shortcuts | [COMMON-CLI.md § OneLake Shortcuts](../../common/COMMON-CLI.md#onelake-shortcuts) ||48| Capacity Management (CLI) | [COMMON-CLI.md § Capacity Management](../../common/COMMON-CLI.md#capacity-management) ||49| Composite Recipes | [COMMON-CLI.md § Composite Recipes](../../common/COMMON-CLI.md#composite-recipes) ||50| Gotchas & Troubleshooting (CLI-Specific) | [COMMON-CLI.md § Gotchas & Troubleshooting (CLI-Specific)](../../common/COMMON-CLI.md#gotchas--troubleshooting-cli-specific) | `az rest` audience, shell escaping, token expiry |51| Quick Reference: `az rest` Template | [COMMON-CLI.md § Quick Reference: az rest Template](../../common/COMMON-CLI.md#quick-reference-az-rest-template) ||52| Quick Reference: Token Audience / CLI Tool Matrix | [COMMON-CLI.md § Quick Reference: Token Audience ↔ CLI Tool Matrix](../../common/COMMON-CLI.md#quick-reference-token-audience--cli-tool-matrix) | Which `--resource` + tool for each service |53| Relationship to SPARK-AUTHORING-CORE.md | [SPARK-CONSUMPTION-CORE.md § Relationship to SPARK-AUTHORING-CORE.md](../../common/SPARK-CONSUMPTION-CORE.md#relationship-to-spark-authoring-coremd) ||54| Data Engineering Consumption Capability Matrix | [SPARK-CONSUMPTION-CORE.md § Data Engineering Consumption Capability Matrix](../../common/SPARK-CONSUMPTION-CORE.md#data-engineering-consumption-capability-matrix) ||55| OneLake Table APIs (Schema-enabled Lakehouses) | [SPARK-CONSUMPTION-CORE.md § OneLake Table APIs (Schema-enabled Lakehouses)](../../common/SPARK-CONSUMPTION-CORE.md#onelake-table-apis-schema-enabled-lakehouses) | Unity Catalog-compatible metadata; requires `storage.azure.com` token |56| Lakehouse Livy Session Management | [SPARK-CONSUMPTION-CORE.md § Livy Session Management](../../common/SPARK-CONSUMPTION-CORE.md#livy-session-management) | Lakehouse Livy API: session creation, states, lifecycle, termination |57| Interactive Data Exploration | [SPARK-CONSUMPTION-CORE.md § Interactive Data Exploration](../../common/SPARK-CONSUMPTION-CORE.md#interactive-data-exploration) | Statement execution, output retrieval, data discovery |58| PySpark Analytics Patterns | [SPARK-CONSUMPTION-CORE.md § PySpark Analytics Patterns](../../common/SPARK-CONSUMPTION-CORE.md#pyspark-analytics-patterns) | Cross-lakehouse 3-part naming, performance optimization |59| Must/Prefer/Avoid | [SKILL.md § Must/Prefer/Avoid](#mustpreferavoid) | **MUST DO / AVOID / PREFER** checklists |60| Quick Start | [SKILL.md § Quick Start](#quick-start) | CLI-specific Lakehouse Livy session setup and data exploration |61| Key Fabric Patterns | [SKILL.md § Key Fabric Patterns](#key-fabric-patterns) | Spark pattern quick-reference table |62| Session Cleanup | [SKILL.md § Session Cleanup](#session-cleanup) | Clean up idle Lakehouse Livy sessions via CLI |6364---6566## Must/Prefer/Avoid6768### MUST DO6970- Check for existing idle sessions before creating new ones71- Use dynamic workspace/lakehouse discovery72- Follow API patterns from [COMMON-CLI.md](../../common/COMMON-CLI.md)7374### PREFER7576- **sqldw-consumption-cli for simple lakehouse queries** — row counts, SELECT, schema exploration, filtering, and aggregation on lakehouse Delta tables should use the SQL Endpoint via `sqlcmd`, not Spark. Only use this skill when the user explicitly requests PySpark, DataFrames, or Spark-specific features.77- SQL Endpoint for Delta tables78- Livy for unstructured/JSON data or complex Python analytics79- Session reuse over creation8081### AVOID8283- Hardcoded workspace IDs84- Creating unnecessary sessions85- Large result sets without LIMIT86- **Confusing Lakehouse Livy sessions with Notebook Spark sessions** — This skill covers **Lakehouse Livy sessions** (the public Livy API at `/lakehouses/{lhId}/livyapi/.../sessions`). Notebook Spark sessions are created internally when running a notebook via the Jobs API (`RunNotebook`) and are NOT managed through the Livy API. To run a notebook as a job, see SPARK-AUTHORING-CORE.md § Notebook Execution & Job Management87- **Writing or generating notebook cells** — prompts that ask for `%%sql`, `%%configure`, PySpark notebook cell code, notebook deployment, or notebook execution belong to `spark-authoring-cli`, even when the cell queries data.8889---9091## Quick Start9293### Environment Setup9495Apply environment detection from COMMON-CORE.md Environment Detection Pattern to set:96- `$FABRIC_API_BASE` and `$FABRIC_RESOURCE_SCOPE`97- `$FABRIC_API_URL` and `$LIVY_API_PATH` for Livy operations9899**Authentication**: Use token acquisition from [COMMON-CLI.md](../../common/COMMON-CLI.md) Environment Detection and API Configuration100101### Workspace & Item Discovery102103**Preferred**: Use [COMMON-CLI.md](../../common/COMMON-CLI.md) item discovery patterns (Finding things in Fabric) to find workspaces and items by name.104105**Fallback** (when workspace is already known):106```bash107# List workspaces108az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces" --query "value[].{name:displayName, id:id}" --output table109read -p "Workspace ID: " workspaceId110111# List lakehouses in workspace112az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/items?type=Lakehouse" --query "value[].{name:displayName, id:id}" --output table 113read -p "Lakehouse ID: " lakehouseId114```115116### Lakehouse Livy Session Management117118> **Two types of Spark sessions in Fabric** — This skill manages **Lakehouse Livy sessions**, created via the public Livy API endpoint (`/lakehouses/{lhId}/livyapi/.../sessions`). These are ad-hoc interactive sessions for remote clients. **Notebook Spark sessions** are a separate mechanism — they are created internally when a Fabric Notebook is executed (via portal or Jobs API `RunNotebook`), and are managed through the notebook lifecycle, not the Livy API.119120```bash121# Check for existing idle Lakehouse Livy session (avoid resource waste)122sessionId=$(az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions" --query "sessions[?state=='idle'][0].id" --output tsv)123124# Create if none available - FORCE STARTER POOL USAGE125if [[ -z "$sessionId" ]]; then126 cat > /tmp/body.json << 'EOF'127{128 "name":"analysis",129 "driverMemory":"56g",130 "driverCores":8,131 "executorMemory":"56g",132 "executorCores":8,133 "conf": {134 "spark.dynamicAllocation.enabled": "true",135 "spark.fabric.pool.name": "Starter Pool"136 }137}138EOF139 sessionId=$(az rest --method post --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions" --body @/tmp/body.json --query "id" --output tsv)140 141 echo "⏳ Waiting for starter pool session to be ready..." 142 # With starter pools, this should be 3-5 seconds143 timeout=30 # Reduced from 90s since starter pools are fast144 while [ $timeout -gt 0 ]; do145 state=$(az rest --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions/$sessionId" --query "state" --output tsv)146 if [[ "$state" == "idle" ]]; then147 echo "✅ Session ready in starter pool!"148 break149 fi150 echo " Session state: $state (${timeout}s remaining)"151 sleep 3152 timeout=$((timeout - 3))153 done154fi155```156157### Data Exploration (Fabric-Specific Patterns)158```bash159# Execute statement (LLM knows Python/Spark syntax)160cat > /tmp/body.json << 'EOF'161{162 "code": "spark.sql(\"SHOW TABLES\").show(); df = spark.table(\"your_table\"); df.describe().show()",163 "kind": "pyspark"164}165EOF166az rest --method post --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions/$sessionId/statements" --body @/tmp/body.json167```168169## Key Fabric Patterns170171| Pattern | Code | Use Case |172|---|---|---|173| **Table Discovery** | `spark.sql("SHOW TABLES")` | List available tables |174| **Cross-Lakehouse** | `spark.sql("SELECT * FROM other_workspace.table")` | Query across workspaces |175| **Delta Features** | `df.history()`, `df.readVersion(1)` | Time travel, versioning |176| **Schema Evolution** | `df.printSchema()` | Understand structure |177178## Lakehouse Livy Session Cleanup179```bash180# Clean up idle Lakehouse Livy sessions (optional)181az rest --method get --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions" --query "sessions[?state=='idle'].id" --output tsv | xargs -I {} az rest --method delete --resource "$FABRIC_RESOURCE_SCOPE" --url "$FABRIC_API_URL/workspaces/$workspaceId/lakehouses/$lakehouseId/$LIVY_API_PATH/sessions/{}"182```183184---185186**Focus**: This skill provides Fabric-specific REST API patterns. LLM already knows Python/Spark syntax — we focus on Fabric integration, session management, and API endpoints.