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
- Eventstream ≠ Eventhouse. Eventstream is a real-time event ingestion and routing pipeline. For KQL database operations, use
eventhouse-authoring-cli or eventhouse-consumption-cli.
Eventstream Authoring — CLI Skill
Table of Contents
| Task |
Reference |
Notes |
| 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 |
| Core Control-Plane REST APIs |
COMMON-CORE.md § Core Control-Plane REST APIs |
Includes pagination, LRO polling, and rate-limiting patterns |
| Gotchas, Best Practices & Troubleshooting |
COMMON-CORE.md § Gotchas, Best Practices & Troubleshooting |
|
| Tool Selection Rationale |
COMMON-CLI.md § Tool Selection Rationale |
|
| 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; includes pagination and LRO helpers |
| Gotchas & Troubleshooting (CLI-Specific) |
COMMON-CLI.md § Gotchas & Troubleshooting (CLI-Specific) |
az rest audience, shell escaping, token expiry |
| Quick Reference |
COMMON-CLI.md § Quick Reference |
az rest template + token audience/tool matrix |
| Eventstream Resource Model |
EVENTSTREAM-AUTHORING-CORE.md § Eventstream Resource Model |
Read first — graph-based topology with sources, operators, streams, destinations |
| Source Configuration |
EVENTSTREAM-AUTHORING-CORE.md § Source Configuration |
25 API-supported source types with per-source properties |
| Transformation Operators |
EVENTSTREAM-AUTHORING-CORE.md § Transformation Operators |
8 operator types: Filter, Aggregate, GroupBy, Join, ManageFields, Union, Expand, SQL |
| Destination Configuration |
EVENTSTREAM-AUTHORING-CORE.md § Destination Configuration |
4 API-supported destination types with node schema |
| Stream Types |
EVENTSTREAM-AUTHORING-CORE.md § Stream Types |
DefaultStream (auto) and DerivedStream (from operators) |
| Eventstream Lifecycle (REST API) |
EVENTSTREAM-AUTHORING-CORE.md § Eventstream Lifecycle (REST API) |
CRUD + Definition endpoints |
| Item Definitions and Deployment |
EVENTSTREAM-AUTHORING-CORE.md § Item Definitions and Deployment |
Base64 encoding pattern for eventstream.json |
| Gotchas and Limitations |
EVENTSTREAM-AUTHORING-CORE.md § Gotchas and Limitations |
Max 11 custom endpoints, base64 encoding, naming constraints |
| Create an Eventstream |
SKILL.md § Create an Eventstream |
|
| Deploy Full Topology |
SKILL.md § Deploy Full Topology |
End-to-end: build topology JSON → base64 encode → submit definition |
| Update Eventstream Topology |
SKILL.md § Update Eventstream Topology |
|
| Delete an Eventstream |
SKILL.md § Delete an Eventstream |
|
| Gotchas, Rules, Troubleshooting |
SKILL.md § Gotchas, Rules, Troubleshooting |
MUST DO / AVOID / PREFER checklists |
Create an Eventstream
Create an empty Eventstream item, then configure it with sources, destinations, and operators via the definition API.
Step 1: Create the Item
az rest --method POST \
--url "https://api.fabric.microsoft.com/v1/workspaces/${WORKSPACE_ID}/eventstreams" \
--resource "https://api.fabric.microsoft.com" \
--headers "Content-Type=application/json" \
--body '{"displayName": "my-eventstream", "description": "IoT sensor pipeline"}'
Save the returned id as EVENTSTREAM_ID.
Step 2: Build the Topology
Construct the eventstream.json topology with sources, streams, operators, and destinations. Each node references its upstream via inputNodes.
Prefer building the JSON programmatically to avoid serialization errors. Key rules:
- The topology must have exactly one DefaultStream — all sources feed into it via
inputNodes
- Operators reference their input via
inputNodes[].name
- DerivedStreams require
inputSerialization in properties
- Destinations reference their input stream or operator
Step 3: Deploy the Definition
Base64-encode the topology JSON and submit via the definition API. See Item Definitions and Deployment for the full payload structure.
Deploy Full Topology
For deploying a complete Eventstream with topology in a single API call, use the Create Item with Definition endpoint:
# 1. Build eventstream.json content (topology)
TOPOLOGY_JSON='{"compatibilityLevel":"1.1","sources":[...],"streams":[...],"operators":[...],"destinations":[...]}'
# 2. Build eventstreamProperties.json (optional — controls retention and throughput)
PROPERTIES_JSON='{"retentionTimeInDays":1,"eventThroughputLevel":"Low"}'
# 3. Base64-encode both (no line wraps)
TOPOLOGY_B64=$(echo -n "$TOPOLOGY_JSON" | base64 -w 0)
PROPERTIES_B64=$(echo -n "$PROPERTIES_JSON" | base64 -w 0)
# 4. Submit via Items API
az rest --method POST \
--url "https://api.fabric.microsoft.com/v1/workspaces/${WORKSPACE_ID}/items" \
--resource "https://api.fabric.microsoft.com" \
--headers "Content-Type=application/json" \
--body "{
\"displayName\": \"my-eventstream\",
\"type\": \"Eventstream\",
\"definition\": {
\"parts\": [
{
\"path\": \"eventstream.json\",
\"payload\": \"${TOPOLOGY_B64}\",
\"payloadType\": \"InlineBase64\"
},
{
\"path\": \"eventstreamProperties.json\",
\"payload\": \"${PROPERTIES_B64}\",
\"payloadType\": \"InlineBase64\"
}
]
}
}"
Note: If eventstreamProperties.json is omitted, the API applies defaults: retentionTimeInDays: 1, eventThroughputLevel: "Low". Include it explicitly to control retention (1–90 days) and throughput.
On Windows (PowerShell), use [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($json)) for base64 encoding.
Update Eventstream Topology
- Get current definition:
POST /v1/workspaces/{wsId}/eventstreams/{esId}/getDefinition
- Decode the
eventstream.json payload from base64
- Modify the topology (add/remove/update nodes)
- Re-encode to base64
- Submit:
POST /v1/workspaces/{wsId}/eventstreams/{esId}/updateDefinition
API Note: The Eventstream Definition APIs use POST with action verbs (getDefinition, updateDefinition), not GET/PUT on a /definition resource. This follows the Fabric Items Definition pattern. See official docs.
The Update Definition API returns 202 Accepted for long-running operations. Poll the Location header URL until completion.
Adding a Filter Operator
⚠️ CRITICAL: Filter operator conditions use nested objects for column and value — NOT bare strings. Using "column": "temperature" instead of the object form below will cause a silent API rejection.
{
"name": "FilterHighTemp",
"type": "Filter",
"inputNodes": [{"name": "my-stream"}],
"properties": {
"conditions": [{
"column": {
"node": null,
"columnName": "temperature",
"columnPath": null,
"expressionType": "ColumnReference"
},
"operatorType": "GreaterThan",
"value": {
"dataType": "Float",
"value": "30.0",
"expressionType": "Literal"
}
}]
}
}
Required structure for ALL operator condition fields:
column → object with {node, columnName, columnPath, expressionType: "ColumnReference"}
value → object with {dataType, value, expressionType: "Literal"}
operatorType → string: Equals, NotEquals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, Contains, DoesNotContain, StartsWith, DoesNotStartWith, EndsWith, DoesNotEndWith, IsEmpty, IsNull, IsNotNull, IsNotNullOrEmpty
dataType → BigInt, Float, Nvarchar(max), DateTime, Bit
This same nested-object pattern applies to all operators that reference columns (Filter, Aggregate, GroupBy, Join, ManageFields).
Delete an Eventstream
az rest --method DELETE \
--url "https://api.fabric.microsoft.com/v1/workspaces/${WORKSPACE_ID}/eventstreams/${EVENTSTREAM_ID}" \
--resource "https://api.fabric.microsoft.com"
Returns 200 OK on success.
Gotchas, Rules, Troubleshooting
MUST DO
- Always base64-encode the
eventstream.json payload before submitting definitions
- Always pass
--resource https://api.fabric.microsoft.com with az rest calls
- Always use JMESPath filtering to resolve workspace name → ID and item name → ID
- Always use nested objects for operator column/value references —
"column": {"columnName": "x", "expressionType": "ColumnReference", ...}, never "column": "x" (API rejects bare strings silently)
- Exactly one DefaultStream per topology — all sources connect to it (the API rejects multiple DefaultStreams)
- Poll LRO responses — Update Definition returns
202 Accepted with a Location header
PREFER
- Build topology JSON programmatically rather than manual string construction
- Use
SampleData source type for testing and prototyping
- Set
retentionTimeInDays explicitly rather than relying on defaults
- Validate cloud connections before referencing them in source configurations
- Use DerivedStreams to make operator output available in Real-Time Hub
AVOID
- Do NOT use raw JSON in the definition payload — it must be base64-encoded
- Do NOT use underscores or dots in Eventstream display names (breaks SQL operator)
- Do NOT use hyphens, underscores, dots, or spaces in user-defined topology node names (sources, operators, DerivedStreams, destinations) — only alphanumeric PascalCase is allowed (e.g., use
FilterTemperature not filter-temperature or filter_temperature). Exception: DefaultStream names are auto-generated by the platform as {eventstreamName}-stream and may contain hyphens — do not rename them
- Do NOT exceed 11 combined CustomEndpoint sources and CustomEndpoint/Eventhouse-direct-ingestion destinations
- Do NOT confuse Eventstream with Eventhouse — they are separate Fabric workloads
- Do NOT hardcode workspace or item IDs — always discover them via the API
Examples
Platform note — examples use PowerShell. Always write the JSON body to
a temp file via [IO.File]::WriteAllText() (no BOM) and pass
--body "@$file" to az rest, rather than inline --body "..." which
cmd.exe can mangle. Use -Compress with ConvertTo-Json to avoid
newline issues. The one safe inline exception is --body '{}' for empty bodies.
Example 1: Create an Eventstream with a Source
Prompt: "Create an Eventstream called SensorIngestion in my dev workspace with a sample data source."
# 1. Discover workspace ID
$wsId = (az rest --method get `
--url "https://api.fabric.microsoft.com/v1/workspaces" `
--resource "https://api.fabric.microsoft.com" `
--query "value[?displayName=='dev'] | [0].id" -o tsv)
if (-not $wsId) { throw "Workspace 'dev' not found" }
# 2. Create empty Eventstream
$esBody = @{ displayName = "SensorIngestion"; description = "IoT sensor pipeline" } | ConvertTo-Json -Compress
$bodyFile = Join-Path ([IO.Path]::GetTempPath()) "es_create.json"
[IO.File]::WriteAllText($bodyFile, $esBody, [System.Text.UTF8Encoding]::new($false))
$created = az rest --method post `
--url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams" `
--resource "https://api.fabric.microsoft.com" `
--headers "Content-Type=application/json" `
--body "@$bodyFile" | ConvertFrom-Json
# 3. Get the created Eventstream ID from response
$esId = $created.id
if (-not $esId) { throw "Eventstream creation did not return an ID" }
# 4. Build topology — DefaultStream uses inputNodes (not parentName)
$topology = @{
compatibilityLevel = "1.0"
sources = @(@{
name = "SampleSource"
type = "SampleData"
properties = @{ type = "Bicycles" }
})
streams = @(@{
name = "SensorIngestion-stream"
type = "DefaultStream"
properties = @{}
inputNodes = @(@{ name = "SampleSource" })
})
operators = @()
destinations = @()
}
$topologyJson = $topology | ConvertTo-Json -Depth 10 -Compress
$topologyB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($topologyJson))
# 5. Deploy definition
$defBody = @{
definition = @{
parts = @(@{
path = "eventstream.json"
payload = $topologyB64
payloadType = "InlineBase64"
})
}
} | ConvertTo-Json -Depth 5 -Compress
$defFile = Join-Path ([IO.Path]::GetTempPath()) "es_def.json"
[IO.File]::WriteAllText($defFile, $defBody, [System.Text.UTF8Encoding]::new($false))
# updateDefinition returns 202 Accepted (LRO). Use Invoke-WebRequest to capture headers.
$token = (az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)
$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }
$response = Invoke-WebRequest @ps5 -Method Post `
-Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId/updateDefinition" `
-Headers @{ Authorization = "Bearer $token" } `
-ContentType "application/json; charset=utf-8" `
-Body (Get-Content $defFile -Raw -Encoding UTF8)
if ($response.StatusCode -eq 202) {
$location = $response.Headers['Location']
if ($location -is [array]) { $location = $location[0] }
if (-not $location) { throw "LRO response missing Location header" }
$ra = $response.Headers['Retry-After']
if ($ra -is [array]) { $ra = $ra[0] }
$retryAfter = if ($ra) { [int]$ra } else { 5 }
$succeeded = $false
for ($i = 0; $i -lt 12; $i++) {
Start-Sleep -Seconds $retryAfter
$poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }
if ($poll.status -eq 'Succeeded') { $succeeded = $true; Write-Host "Update succeeded"; break }
elseif ($poll.status -in @('Failed', 'Cancelled')) {
throw "updateDefinition LRO $($poll.status): $($poll.error.message)"
}
}
if (-not $succeeded) { throw "updateDefinition LRO timed out" }
}
Example 2: Add a Filter Operator with a DerivedStream
Prompt: "Add a filter to my SensorIngestion Eventstream that keeps only events where No_Bikes > 5 and expose the filtered output as a DerivedStream."
Important: Adding a Filter operator node alone does not redirect the DefaultStream.
To make the filtered output consumable, wire a DerivedStream (or destination) to the
filter's output via inputNodes.
# 1. Discover workspace + Eventstream IDs
$wsId = (az rest --method get `
--url "https://api.fabric.microsoft.com/v1/workspaces" `
--resource "https://api.fabric.microsoft.com" `
--query "value[?displayName=='dev'] | [0].id" -o tsv)
if (-not $wsId) { throw "Workspace 'dev' not found" }
$esId = (az rest --method get `
--url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams" `
--resource "https://api.fabric.microsoft.com" `
--query "value[?displayName=='SensorIngestion'] | [0].id" -o tsv)
if (-not $esId) { throw "Eventstream 'SensorIngestion' not found" }
# 2. Get current definition (handles LRO via Location header)
$token = (az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)
$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }
$response = Invoke-WebRequest @ps5 -Method Post `
-Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId/getDefinition" `
-Headers @{ Authorization = "Bearer $token"; "Content-Type" = "application/json" } `
-Body '{}'
if ($response.StatusCode -eq 202) {
$location = $response.Headers['Location']
if ($location -is [array]) { $location = $location[0] }
if (-not $location) { throw "LRO response missing Location header" }
$ra = $response.Headers['Retry-After']
if ($ra -is [array]) { $ra = $ra[0] }
$retryAfter = if ($ra) { [int]$ra } else { 5 }
$def = $null
for ($i = 0; $i -lt 12; $i++) {
Start-Sleep -Seconds $retryAfter
$poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }
if ($poll.status -eq 'Succeeded') {
$def = Invoke-RestMethod -Uri "$location/result" `
-Headers @{ Authorization = "Bearer $token" }
break
} elseif ($poll.status -in @('Failed', 'Cancelled')) {
throw "getDefinition LRO $($poll.status): $($poll.error.message)"
}
}
if (-not $def -or -not $def.definition) { throw "getDefinition LRO timed out (last status: $(if ($poll) { $poll.status } else { 'unknown' }))" }
} else {
$def = $response.Content | ConvertFrom-Json
}
# 3. Decode existing topology
$esPart = $def.definition.parts | Where-Object { $_.path -eq 'eventstream.json' } | Select-Object -First 1
if (-not $esPart) { throw "eventstream.json part not found in definition" }
$topology = [Text.Encoding]::UTF8.GetString(
[Convert]::FromBase64String($esPart.payload)) | ConvertFrom-Json
# 4. Add Filter operator (PascalCase name — no underscores or hyphens)
# Column: expressionType + columnName; Value: expressionType + dataType + value
$filter = @{
name = "FilterLowBikes"
type = "Filter"
inputNodes = @(@{ name = "SensorIngestion-stream" })
properties = @{
conditions = @(@{
operatorType = "GreaterThan"
column = @{
expressionType = "ColumnReference"
node = $null
columnName = "No_Bikes"
columnPath = $null
}
value = @{
expressionType = "Literal"
dataType = "BigInt"
value = "5"
}
})
}
}
$existingOps = @($topology.operators | Where-Object { $_ -ne $null })
$topology.operators = $existingOps + @($filter)
# 5. Add DerivedStream wired to filter output (makes filtered data available)
$derivedStream = @{
name = "FilteredOutput"
type = "DerivedStream"
properties = @{
inputSerialization = @{ type = "Json"; properties = @{ encoding = "UTF8" } }
}
inputNodes = @(@{ name = "FilterLowBikes" })
}
$existingStreams = @($topology.streams | Where-Object { $_ -ne $null })
$topology.streams = $existingStreams + @($derivedStream)
# 6. Re-encode and update
$topologyJson = $topology | ConvertTo-Json -Depth 10 -Compress
$topologyB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($topologyJson))
$esPart.payload = $topologyB64
$defBody = @{ definition = @{ parts = $def.definition.parts } } | ConvertTo-Json -Depth 5 -Compress
$defFile = Join-Path ([IO.Path]::GetTempPath()) "es_def.json"
[IO.File]::WriteAllText($defFile, $defBody, [System.Text.UTF8Encoding]::new($false))
# updateDefinition returns 202 Accepted (LRO). Use Invoke-WebRequest to capture headers.
$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }
$response = Invoke-WebRequest @ps5 -Method Post `
-Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId/updateDefinition" `
-Headers @{ Authorization = "Bearer $token" } `
-ContentType "application/json; charset=utf-8" `
-Body (Get-Content $defFile -Raw -Encoding UTF8)
if ($response.StatusCode -eq 202) {
$location = $response.Headers['Location']
if ($location -is [array]) { $location = $location[0] }
if (-not $location) { throw "LRO response missing Location header" }
$ra = $response.Headers['Retry-After']
if ($ra -is [array]) { $ra = $ra[0] }
$retryAfter = if ($ra) { [int]$ra } else { 5 }
$succeeded = $false
for ($i = 0; $i -lt 12; $i++) {
Start-Sleep -Seconds $retryAfter
$poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }
if ($poll.status -eq 'Succeeded') { $succeeded = $true; Write-Host "Update succeeded"; break }
elseif ($poll.status -in @('Failed', 'Cancelled')) {
throw "updateDefinition LRO $($poll.status): $($poll.error.message)"
}
}
if (-not $succeeded) { throw "updateDefinition LRO timed out" }
}
Example 3: Deploy Full Topology (Create with Inline Definition)
Prompt: "Create a complete Eventstream called EventPipeline with a Custom Endpoint source, a filter for high-value events, and a DerivedStream for the filtered output."
Note: This uses the Fabric Items API (POST /items) to create the Eventstream with its
definition in a single call, rather than create-then-update.
# 1. Discover workspace ID
$wsId = (az rest --method get `
--url "https://api.fabric.microsoft.com/v1/workspaces" `
--resource "https://api.fabric.microsoft.com" `
--query "value[?displayName=='dev'] | [0].id" -o tsv)
if (-not $wsId) { throw "Workspace 'dev' not found" }
# 2. Build complete topology with filter + DerivedStream
$topology = @{
compatibilityLevel = "1.0"
sources = @(@{
name = "CustomSource"
type = "CustomEndpoint"
properties = @{}
})
streams = @(
@{
name = "EventPipeline-stream"
type = "DefaultStream"
properties = @{}
inputNodes = @(@{ name = "CustomSource" })
}
@{
name = "FilteredEvents"
type = "DerivedStream"
properties = @{
inputSerialization = @{ type = "Json"; properties = @{ encoding = "UTF8" } }
}
inputNodes = @(@{ name = "FilterPremium" })
}
)
operators = @(@{
name = "FilterPremium"
type = "Filter"
inputNodes = @(@{ name = "EventPipeline-stream" })
properties = @{
conditions = @(@{
operatorType = "GreaterThan"
column = @{
expressionType = "ColumnReference"
node = $null
columnName = "Amount"
columnPath = $null
}
value = @{
expressionType = "Literal"
dataType = "BigInt"
value = "100"
}
})
}
})
destinations = @()
}
# 3. Create with inline definition (single API call)
$topologyJson = $topology | ConvertTo-Json -Depth 10 -Compress
$topologyB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($topologyJson))
$body = @{
displayName = "EventPipeline"
type = "Eventstream"
definition = @{
parts = @(@{
path = "eventstream.json"
payload = $topologyB64
payloadType = "InlineBase64"
})
}
} | ConvertTo-Json -Depth 5 -Compress
$bodyFile = Join-Path ([IO.Path]::GetTempPath()) "es_create_full.json"
[IO.File]::WriteAllText($bodyFile, $body, [System.Text.UTF8Encoding]::new($false))
# Create-with-definition returns 202 Accepted (LRO). Use Invoke-WebRequest to capture headers.
$token = (az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)
$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }
$response = Invoke-WebRequest @ps5 -Method Post `
-Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/items" `
-Headers @{ Authorization = "Bearer $token" } `
-ContentType "application/json; charset=utf-8" `
-Body (Get-Content $bodyFile -Raw -Encoding UTF8)
if ($response.StatusCode -eq 202) {
$location = $response.Headers['Location']
if ($location -is [array]) { $location = $location[0] }
if (-not $location) { throw "LRO response missing Location header" }
$ra = $response.Headers['Retry-After']
if ($ra -is [array]) { $ra = $ra[0] }
$retryAfter = if ($ra) { [int]$ra } else { 10 }
$succeeded = $false
for ($i = 0; $i -lt 12; $i++) {
Start-Sleep -Seconds $retryAfter
$poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }
if ($poll.status -eq 'Succeeded') { $succeeded = $true; Write-Host "Create succeeded"; break }
elseif ($poll.status -in @('Failed', 'Cancelled')) {
throw "Create LRO $($poll.status): $($poll.error.message)"
}
}
if (-not $succeeded) { throw "Create LRO timed out" }
} else {
Write-Host "Created: $(($response.Content | ConvertFrom-Json).displayName)"
}
Example 4: Delete an Eventstream
Prompt: "Delete the SensorIngestion Eventstream from my dev workspace."
# 1. Discover workspace + Eventstream IDs
$wsId = (az rest --method get `
--url "https://api.fabric.microsoft.com/v1/workspaces" `
--resource "https://api.fabric.microsoft.com" `
--query "value[?displayName=='dev'] | [0].id" -o tsv)
if (-not $wsId) { throw "Workspace 'dev' not found" }
$esId = (az rest --method get `
--url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams" `
--resource "https://api.fabric.microsoft.com" `
--query "value[?displayName=='SensorIngestion'] | [0].id" -o tsv)
if (-not $esId) { throw "Eventstream 'SensorIngestion' not found" }
# 2. Delete
az rest --method delete `
--url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId" `
--resource "https://api.fabric.microsoft.com"
1---2name: eventstream-authoring-cli3description: Create, wire, and publish Fabric Eventstream real-time streaming topologies via the Items REST API. Build definitions with 25 source types (Event Hubs, IoT Hub, CDC, Kafka, SampleData), 8 operators (Filter, Aggregate, GroupBy, Join, ManageFields, Union, Expand, SQL), 4 destinations (Lakehouse, Eventhouse, Activator, Custom Endpoint), DefaultStream/DerivedStream routing. **Invoke this skill** to: (1) author Eventstream topology, (2) add Event Hub source, (3) add filter operator, (4) add CDC source with Debezium flattening, (5) wire destinations, (6) modify/delete Eventstream definitions. Invoke before making topology changes. Triggers: "create eventstream", "deploy eventstream", "eventstream topology", "add source to eventstream", "add event hub source", "add filter operator", "eventstream filter", "eventstream destination", "CDC source", "eventstream operator", "eventstream definition", "update eventstream", "wire eventstream", "real-time ingestion pipeline", "eventstream topology deployment".4---56> **Update Check — ONCE PER SESSION (mandatory)**7> The first time this skill is used in a session, run the **check-updates** skill before proceeding.8> - **GitHub Copilot CLI / VS Code**: invoke the `check-updates` skill.9> - **Claude Code / Cowork / Cursor / Windsurf / Codex**: compare local vs remote package.json version.10> - Skip if the check was already performed earlier in this session.1112> **CRITICAL NOTES**13> 1. To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering14> 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 filtering15> 3. Eventstream ≠ Eventhouse. Eventstream is a real-time event ingestion and routing pipeline. For KQL database operations, use `eventhouse-authoring-cli` or `eventhouse-consumption-cli`.1617# Eventstream Authoring — CLI Skill1819## Table of Contents2021| Task | Reference | Notes |22|---|---|---|23| 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] |24| Fabric Topology & Key Concepts | [COMMON-CORE.md § Fabric Topology & Key Concepts](../../common/COMMON-CORE.md#fabric-topology--key-concepts) | |25| Environment URLs | [COMMON-CORE.md § Environment URLs](../../common/COMMON-CORE.md#environment-urls) | |26| Authentication & Token Acquisition | [COMMON-CORE.md § Authentication & Token Acquisition](../../common/COMMON-CORE.md#authentication--token-acquisition) | Wrong audience = 401; read before any auth issue |27| Core Control-Plane REST APIs | [COMMON-CORE.md § Core Control-Plane REST APIs](../../common/COMMON-CORE.md#core-control-plane-rest-apis) | Includes pagination, LRO polling, and rate-limiting patterns |28| Gotchas, Best Practices & Troubleshooting | [COMMON-CORE.md § Gotchas, Best Practices & Troubleshooting](../../common/COMMON-CORE.md#gotchas-best-practices--troubleshooting) | |29| Tool Selection Rationale | [COMMON-CLI.md § Tool Selection Rationale](../../common/COMMON-CLI.md#tool-selection-rationale) | |30| Authentication Recipes | [COMMON-CLI.md § Authentication Recipes](../../common/COMMON-CLI.md#authentication-recipes) | `az login` flows and token acquisition |31| 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`**; includes pagination and LRO helpers |32| 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 |33| Quick Reference | [COMMON-CLI.md § Quick Reference](../../common/COMMON-CLI.md#quick-reference) | `az rest` template + token audience/tool matrix |34| Eventstream Resource Model | [EVENTSTREAM-AUTHORING-CORE.md § Eventstream Resource Model](../../common/EVENTSTREAM-AUTHORING-CORE.md#eventstream-resource-model) | **Read first** — graph-based topology with sources, operators, streams, destinations |35| Source Configuration | [EVENTSTREAM-AUTHORING-CORE.md § Source Configuration](../../common/EVENTSTREAM-AUTHORING-CORE.md#source-configuration) | 25 API-supported source types with per-source properties |36| Transformation Operators | [EVENTSTREAM-AUTHORING-CORE.md § Transformation Operators](../../common/EVENTSTREAM-AUTHORING-CORE.md#transformation-operators) | 8 operator types: Filter, Aggregate, GroupBy, Join, ManageFields, Union, Expand, SQL |37| Destination Configuration | [EVENTSTREAM-AUTHORING-CORE.md § Destination Configuration](../../common/EVENTSTREAM-AUTHORING-CORE.md#destination-configuration) | 4 API-supported destination types with node schema |38| Stream Types | [EVENTSTREAM-AUTHORING-CORE.md § Stream Types](../../common/EVENTSTREAM-AUTHORING-CORE.md#stream-types) | DefaultStream (auto) and DerivedStream (from operators) |39| Eventstream Lifecycle (REST API) | [EVENTSTREAM-AUTHORING-CORE.md § Eventstream Lifecycle (REST API)](../../common/EVENTSTREAM-AUTHORING-CORE.md#eventstream-lifecycle-rest-api) | CRUD + Definition endpoints |40| Item Definitions and Deployment | [EVENTSTREAM-AUTHORING-CORE.md § Item Definitions and Deployment](../../common/EVENTSTREAM-AUTHORING-CORE.md#item-definitions-and-deployment) | Base64 encoding pattern for eventstream.json |41| Gotchas and Limitations | [EVENTSTREAM-AUTHORING-CORE.md § Gotchas and Limitations](../../common/EVENTSTREAM-AUTHORING-CORE.md#gotchas-and-limitations) | Max 11 custom endpoints, base64 encoding, naming constraints |42| Create an Eventstream | [SKILL.md § Create an Eventstream](#create-an-eventstream) | |43| Deploy Full Topology | [SKILL.md § Deploy Full Topology](#deploy-full-topology) | End-to-end: build topology JSON → base64 encode → submit definition |44| Update Eventstream Topology | [SKILL.md § Update Eventstream Topology](#update-eventstream-topology) | |45| Delete an Eventstream | [SKILL.md § Delete an Eventstream](#delete-an-eventstream) | |46| Gotchas, Rules, Troubleshooting | [SKILL.md § Gotchas, Rules, Troubleshooting](#gotchas-rules-troubleshooting) | **MUST DO / AVOID / PREFER** checklists |4748---4950## Create an Eventstream5152Create an empty Eventstream item, then configure it with sources, destinations, and operators via the definition API.5354### Step 1: Create the Item5556```bash57az rest --method POST \58 --url "https://api.fabric.microsoft.com/v1/workspaces/${WORKSPACE_ID}/eventstreams" \59 --resource "https://api.fabric.microsoft.com" \60 --headers "Content-Type=application/json" \61 --body '{"displayName": "my-eventstream", "description": "IoT sensor pipeline"}'62```6364Save the returned `id` as `EVENTSTREAM_ID`.6566### Step 2: Build the Topology6768Construct the `eventstream.json` topology with sources, streams, operators, and destinations. Each node references its upstream via `inputNodes`.6970Prefer building the JSON programmatically to avoid serialization errors. Key rules:71- The topology must have exactly one DefaultStream — all sources feed into it via `inputNodes`72- Operators reference their input via `inputNodes[].name`73- DerivedStreams require `inputSerialization` in properties74- Destinations reference their input stream or operator7576### Step 3: Deploy the Definition7778Base64-encode the topology JSON and submit via the definition API. See [Item Definitions and Deployment](../../common/EVENTSTREAM-AUTHORING-CORE.md#item-definitions-and-deployment) for the full payload structure.7980---8182## Deploy Full Topology8384For deploying a complete Eventstream with topology in a single API call, use the Create Item with Definition endpoint:8586```bash87# 1. Build eventstream.json content (topology)88TOPOLOGY_JSON='{"compatibilityLevel":"1.1","sources":[...],"streams":[...],"operators":[...],"destinations":[...]}'8990# 2. Build eventstreamProperties.json (optional — controls retention and throughput)91PROPERTIES_JSON='{"retentionTimeInDays":1,"eventThroughputLevel":"Low"}'9293# 3. Base64-encode both (no line wraps)94TOPOLOGY_B64=$(echo -n "$TOPOLOGY_JSON" | base64 -w 0)95PROPERTIES_B64=$(echo -n "$PROPERTIES_JSON" | base64 -w 0)9697# 4. Submit via Items API98az rest --method POST \99 --url "https://api.fabric.microsoft.com/v1/workspaces/${WORKSPACE_ID}/items" \100 --resource "https://api.fabric.microsoft.com" \101 --headers "Content-Type=application/json" \102 --body "{103 \"displayName\": \"my-eventstream\",104 \"type\": \"Eventstream\",105 \"definition\": {106 \"parts\": [107 {108 \"path\": \"eventstream.json\",109 \"payload\": \"${TOPOLOGY_B64}\",110 \"payloadType\": \"InlineBase64\"111 },112 {113 \"path\": \"eventstreamProperties.json\",114 \"payload\": \"${PROPERTIES_B64}\",115 \"payloadType\": \"InlineBase64\"116 }117 ]118 }119 }"120```121122> **Note:** If `eventstreamProperties.json` is omitted, the API applies defaults: `retentionTimeInDays: 1`, `eventThroughputLevel: "Low"`. Include it explicitly to control retention (1–90 days) and throughput.123124> On Windows (PowerShell), use `[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($json))` for base64 encoding.125126---127128## Update Eventstream Topology1291301. **Get current definition**: `POST /v1/workspaces/{wsId}/eventstreams/{esId}/getDefinition`1312. **Decode** the `eventstream.json` payload from base641323. **Modify** the topology (add/remove/update nodes)1334. **Re-encode** to base641345. **Submit**: `POST /v1/workspaces/{wsId}/eventstreams/{esId}/updateDefinition`135136> **API Note**: The Eventstream Definition APIs use `POST` with action verbs (`getDefinition`, `updateDefinition`), not `GET`/`PUT` on a `/definition` resource. This follows the Fabric Items Definition pattern. See [official docs](https://learn.microsoft.com/en-us/fabric/real-time-intelligence/event-streams/api-get-eventstream-definition).137138The Update Definition API returns `202 Accepted` for long-running operations. Poll the `Location` header URL until completion.139140### Adding a Filter Operator141142> **⚠️ CRITICAL**: Filter operator conditions use **nested objects** for `column` and `value` — NOT bare strings. Using `"column": "temperature"` instead of the object form below will cause a silent API rejection.143144```json145{146 "name": "FilterHighTemp",147 "type": "Filter",148 "inputNodes": [{"name": "my-stream"}],149 "properties": {150 "conditions": [{151 "column": {152 "node": null,153 "columnName": "temperature",154 "columnPath": null,155 "expressionType": "ColumnReference"156 },157 "operatorType": "GreaterThan",158 "value": {159 "dataType": "Float",160 "value": "30.0",161 "expressionType": "Literal"162 }163 }]164 }165}166```167168**Required structure for ALL operator condition fields:**169- `column` → object with `{node, columnName, columnPath, expressionType: "ColumnReference"}`170- `value` → object with `{dataType, value, expressionType: "Literal"}`171- `operatorType` → string: `Equals`, `NotEquals`, `GreaterThan`, `GreaterThanOrEquals`, `LessThan`, `LessThanOrEquals`, `Contains`, `DoesNotContain`, `StartsWith`, `DoesNotStartWith`, `EndsWith`, `DoesNotEndWith`, `IsEmpty`, `IsNull`, `IsNotNull`, `IsNotNullOrEmpty`172- `dataType` → `BigInt`, `Float`, `Nvarchar(max)`, `DateTime`, `Bit`173174This same nested-object pattern applies to **all operators** that reference columns (Filter, Aggregate, GroupBy, Join, ManageFields).175176---177178## Delete an Eventstream179180```bash181az rest --method DELETE \182 --url "https://api.fabric.microsoft.com/v1/workspaces/${WORKSPACE_ID}/eventstreams/${EVENTSTREAM_ID}" \183 --resource "https://api.fabric.microsoft.com"184```185186Returns `200 OK` on success.187188---189190## Gotchas, Rules, Troubleshooting191192### MUST DO193194- **Always base64-encode** the `eventstream.json` payload before submitting definitions195- **Always pass `--resource https://api.fabric.microsoft.com`** with `az rest` calls196- **Always use JMESPath filtering** to resolve workspace name → ID and item name → ID197- **Always use nested objects for operator column/value references** — `"column": {"columnName": "x", "expressionType": "ColumnReference", ...}`, never `"column": "x"` (API rejects bare strings silently)198- **Exactly one DefaultStream per topology** — all sources connect to it (the API rejects multiple DefaultStreams)199- **Poll LRO responses** — Update Definition returns `202 Accepted` with a `Location` header200201### PREFER202203- Build topology JSON programmatically rather than manual string construction204- Use `SampleData` source type for testing and prototyping205- Set `retentionTimeInDays` explicitly rather than relying on defaults206- Validate cloud connections before referencing them in source configurations207- Use DerivedStreams to make operator output available in Real-Time Hub208209### AVOID210211- Do NOT use raw JSON in the definition payload — it must be base64-encoded212- Do NOT use underscores or dots in Eventstream display names (breaks SQL operator)213- Do NOT use hyphens, underscores, dots, or spaces in **user-defined** topology node names (sources, operators, DerivedStreams, destinations) — only alphanumeric PascalCase is allowed (e.g., use `FilterTemperature` not `filter-temperature` or `filter_temperature`). Exception: DefaultStream names are auto-generated by the platform as `{eventstreamName}-stream` and may contain hyphens — do not rename them214- Do NOT exceed 11 combined CustomEndpoint sources and CustomEndpoint/Eventhouse-direct-ingestion destinations215- Do NOT confuse Eventstream with Eventhouse — they are separate Fabric workloads216- Do NOT hardcode workspace or item IDs — always discover them via the API217218---219220## Examples221222> **Platform note** — examples use PowerShell. Always write the JSON body to223> a temp file via `[IO.File]::WriteAllText()` (no BOM) and pass224> `--body "@$file"` to `az rest`, rather than inline `--body "..."` which225> `cmd.exe` can mangle. Use `-Compress` with `ConvertTo-Json` to avoid226> newline issues. The one safe inline exception is `--body '{}'` for empty bodies.227228### Example 1: Create an Eventstream with a Source229230**Prompt**: "Create an Eventstream called SensorIngestion in my dev workspace with a sample data source."231232```powershell233# 1. Discover workspace ID234$wsId = (az rest --method get `235 --url "https://api.fabric.microsoft.com/v1/workspaces" `236 --resource "https://api.fabric.microsoft.com" `237 --query "value[?displayName=='dev'] | [0].id" -o tsv)238if (-not $wsId) { throw "Workspace 'dev' not found" }239240# 2. Create empty Eventstream241$esBody = @{ displayName = "SensorIngestion"; description = "IoT sensor pipeline" } | ConvertTo-Json -Compress242$bodyFile = Join-Path ([IO.Path]::GetTempPath()) "es_create.json"243[IO.File]::WriteAllText($bodyFile, $esBody, [System.Text.UTF8Encoding]::new($false))244$created = az rest --method post `245 --url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams" `246 --resource "https://api.fabric.microsoft.com" `247 --headers "Content-Type=application/json" `248 --body "@$bodyFile" | ConvertFrom-Json249250# 3. Get the created Eventstream ID from response251$esId = $created.id252if (-not $esId) { throw "Eventstream creation did not return an ID" }253254# 4. Build topology — DefaultStream uses inputNodes (not parentName)255$topology = @{256 compatibilityLevel = "1.0"257 sources = @(@{258 name = "SampleSource"259 type = "SampleData"260 properties = @{ type = "Bicycles" }261 })262 streams = @(@{263 name = "SensorIngestion-stream"264 type = "DefaultStream"265 properties = @{}266 inputNodes = @(@{ name = "SampleSource" })267 })268 operators = @()269 destinations = @()270}271$topologyJson = $topology | ConvertTo-Json -Depth 10 -Compress272$topologyB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($topologyJson))273274# 5. Deploy definition275$defBody = @{276 definition = @{277 parts = @(@{278 path = "eventstream.json"279 payload = $topologyB64280 payloadType = "InlineBase64"281 })282 }283} | ConvertTo-Json -Depth 5 -Compress284$defFile = Join-Path ([IO.Path]::GetTempPath()) "es_def.json"285[IO.File]::WriteAllText($defFile, $defBody, [System.Text.UTF8Encoding]::new($false))286# updateDefinition returns 202 Accepted (LRO). Use Invoke-WebRequest to capture headers.287$token = (az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)288$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }289$response = Invoke-WebRequest @ps5 -Method Post `290 -Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId/updateDefinition" `291 -Headers @{ Authorization = "Bearer $token" } `292 -ContentType "application/json; charset=utf-8" `293 -Body (Get-Content $defFile -Raw -Encoding UTF8)294295if ($response.StatusCode -eq 202) {296 $location = $response.Headers['Location']297 if ($location -is [array]) { $location = $location[0] }298 if (-not $location) { throw "LRO response missing Location header" }299 $ra = $response.Headers['Retry-After']300 if ($ra -is [array]) { $ra = $ra[0] }301 $retryAfter = if ($ra) { [int]$ra } else { 5 }302 $succeeded = $false303 for ($i = 0; $i -lt 12; $i++) {304 Start-Sleep -Seconds $retryAfter305 $poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }306 if ($poll.status -eq 'Succeeded') { $succeeded = $true; Write-Host "Update succeeded"; break }307 elseif ($poll.status -in @('Failed', 'Cancelled')) {308 throw "updateDefinition LRO $($poll.status): $($poll.error.message)"309 }310 }311 if (-not $succeeded) { throw "updateDefinition LRO timed out" }312}313```314315### Example 2: Add a Filter Operator with a DerivedStream316317**Prompt**: "Add a filter to my SensorIngestion Eventstream that keeps only events where No_Bikes > 5 and expose the filtered output as a DerivedStream."318319> **Important**: Adding a Filter operator node alone does not redirect the DefaultStream.320> To make the filtered output consumable, wire a DerivedStream (or destination) to the321> filter's output via `inputNodes`.322323```powershell324# 1. Discover workspace + Eventstream IDs325$wsId = (az rest --method get `326 --url "https://api.fabric.microsoft.com/v1/workspaces" `327 --resource "https://api.fabric.microsoft.com" `328 --query "value[?displayName=='dev'] | [0].id" -o tsv)329if (-not $wsId) { throw "Workspace 'dev' not found" }330331$esId = (az rest --method get `332 --url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams" `333 --resource "https://api.fabric.microsoft.com" `334 --query "value[?displayName=='SensorIngestion'] | [0].id" -o tsv)335if (-not $esId) { throw "Eventstream 'SensorIngestion' not found" }336337# 2. Get current definition (handles LRO via Location header)338$token = (az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)339$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }340$response = Invoke-WebRequest @ps5 -Method Post `341 -Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId/getDefinition" `342 -Headers @{ Authorization = "Bearer $token"; "Content-Type" = "application/json" } `343 -Body '{}'344345if ($response.StatusCode -eq 202) {346 $location = $response.Headers['Location']347 if ($location -is [array]) { $location = $location[0] }348 if (-not $location) { throw "LRO response missing Location header" }349 $ra = $response.Headers['Retry-After']350 if ($ra -is [array]) { $ra = $ra[0] }351 $retryAfter = if ($ra) { [int]$ra } else { 5 }352 $def = $null353 for ($i = 0; $i -lt 12; $i++) {354 Start-Sleep -Seconds $retryAfter355 $poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }356 if ($poll.status -eq 'Succeeded') {357 $def = Invoke-RestMethod -Uri "$location/result" `358 -Headers @{ Authorization = "Bearer $token" }359 break360 } elseif ($poll.status -in @('Failed', 'Cancelled')) {361 throw "getDefinition LRO $($poll.status): $($poll.error.message)"362 }363 }364 if (-not $def -or -not $def.definition) { throw "getDefinition LRO timed out (last status: $(if ($poll) { $poll.status } else { 'unknown' }))" }365} else {366 $def = $response.Content | ConvertFrom-Json367}368369# 3. Decode existing topology370$esPart = $def.definition.parts | Where-Object { $_.path -eq 'eventstream.json' } | Select-Object -First 1371if (-not $esPart) { throw "eventstream.json part not found in definition" }372$topology = [Text.Encoding]::UTF8.GetString(373 [Convert]::FromBase64String($esPart.payload)) | ConvertFrom-Json374375# 4. Add Filter operator (PascalCase name — no underscores or hyphens)376# Column: expressionType + columnName; Value: expressionType + dataType + value377$filter = @{378 name = "FilterLowBikes"379 type = "Filter"380 inputNodes = @(@{ name = "SensorIngestion-stream" })381 properties = @{382 conditions = @(@{383 operatorType = "GreaterThan"384 column = @{385 expressionType = "ColumnReference"386 node = $null387 columnName = "No_Bikes"388 columnPath = $null389 }390 value = @{391 expressionType = "Literal"392 dataType = "BigInt"393 value = "5"394 }395 })396 }397}398$existingOps = @($topology.operators | Where-Object { $_ -ne $null })399$topology.operators = $existingOps + @($filter)400401# 5. Add DerivedStream wired to filter output (makes filtered data available)402$derivedStream = @{403 name = "FilteredOutput"404 type = "DerivedStream"405 properties = @{406 inputSerialization = @{ type = "Json"; properties = @{ encoding = "UTF8" } }407 }408 inputNodes = @(@{ name = "FilterLowBikes" })409}410$existingStreams = @($topology.streams | Where-Object { $_ -ne $null })411$topology.streams = $existingStreams + @($derivedStream)412413# 6. Re-encode and update414$topologyJson = $topology | ConvertTo-Json -Depth 10 -Compress415$topologyB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($topologyJson))416$esPart.payload = $topologyB64417418$defBody = @{ definition = @{ parts = $def.definition.parts } } | ConvertTo-Json -Depth 5 -Compress419$defFile = Join-Path ([IO.Path]::GetTempPath()) "es_def.json"420[IO.File]::WriteAllText($defFile, $defBody, [System.Text.UTF8Encoding]::new($false))421# updateDefinition returns 202 Accepted (LRO). Use Invoke-WebRequest to capture headers.422$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }423$response = Invoke-WebRequest @ps5 -Method Post `424 -Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId/updateDefinition" `425 -Headers @{ Authorization = "Bearer $token" } `426 -ContentType "application/json; charset=utf-8" `427 -Body (Get-Content $defFile -Raw -Encoding UTF8)428429if ($response.StatusCode -eq 202) {430 $location = $response.Headers['Location']431 if ($location -is [array]) { $location = $location[0] }432 if (-not $location) { throw "LRO response missing Location header" }433 $ra = $response.Headers['Retry-After']434 if ($ra -is [array]) { $ra = $ra[0] }435 $retryAfter = if ($ra) { [int]$ra } else { 5 }436 $succeeded = $false437 for ($i = 0; $i -lt 12; $i++) {438 Start-Sleep -Seconds $retryAfter439 $poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }440 if ($poll.status -eq 'Succeeded') { $succeeded = $true; Write-Host "Update succeeded"; break }441 elseif ($poll.status -in @('Failed', 'Cancelled')) {442 throw "updateDefinition LRO $($poll.status): $($poll.error.message)"443 }444 }445 if (-not $succeeded) { throw "updateDefinition LRO timed out" }446}447```448449### Example 3: Deploy Full Topology (Create with Inline Definition)450451**Prompt**: "Create a complete Eventstream called EventPipeline with a Custom Endpoint source, a filter for high-value events, and a DerivedStream for the filtered output."452453> **Note**: This uses the Fabric Items API (`POST /items`) to create the Eventstream with its454> definition in a single call, rather than create-then-update.455456```powershell457# 1. Discover workspace ID458$wsId = (az rest --method get `459 --url "https://api.fabric.microsoft.com/v1/workspaces" `460 --resource "https://api.fabric.microsoft.com" `461 --query "value[?displayName=='dev'] | [0].id" -o tsv)462if (-not $wsId) { throw "Workspace 'dev' not found" }463464# 2. Build complete topology with filter + DerivedStream465$topology = @{466 compatibilityLevel = "1.0"467 sources = @(@{468 name = "CustomSource"469 type = "CustomEndpoint"470 properties = @{}471 })472 streams = @(473 @{474 name = "EventPipeline-stream"475 type = "DefaultStream"476 properties = @{}477 inputNodes = @(@{ name = "CustomSource" })478 }479 @{480 name = "FilteredEvents"481 type = "DerivedStream"482 properties = @{483 inputSerialization = @{ type = "Json"; properties = @{ encoding = "UTF8" } }484 }485 inputNodes = @(@{ name = "FilterPremium" })486 }487 )488 operators = @(@{489 name = "FilterPremium"490 type = "Filter"491 inputNodes = @(@{ name = "EventPipeline-stream" })492 properties = @{493 conditions = @(@{494 operatorType = "GreaterThan"495 column = @{496 expressionType = "ColumnReference"497 node = $null498 columnName = "Amount"499 columnPath = $null500 }501 value = @{502 expressionType = "Literal"503 dataType = "BigInt"504 value = "100"505 }506 })507 }508 })509 destinations = @()510}511512# 3. Create with inline definition (single API call)513$topologyJson = $topology | ConvertTo-Json -Depth 10 -Compress514$topologyB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($topologyJson))515516$body = @{517 displayName = "EventPipeline"518 type = "Eventstream"519 definition = @{520 parts = @(@{521 path = "eventstream.json"522 payload = $topologyB64523 payloadType = "InlineBase64"524 })525 }526} | ConvertTo-Json -Depth 5 -Compress527$bodyFile = Join-Path ([IO.Path]::GetTempPath()) "es_create_full.json"528[IO.File]::WriteAllText($bodyFile, $body, [System.Text.UTF8Encoding]::new($false))529530# Create-with-definition returns 202 Accepted (LRO). Use Invoke-WebRequest to capture headers.531$token = (az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)532$ps5 = @{}; if ($PSVersionTable.PSVersion.Major -lt 6) { $ps5.UseBasicParsing = $true }533$response = Invoke-WebRequest @ps5 -Method Post `534 -Uri "https://api.fabric.microsoft.com/v1/workspaces/$wsId/items" `535 -Headers @{ Authorization = "Bearer $token" } `536 -ContentType "application/json; charset=utf-8" `537 -Body (Get-Content $bodyFile -Raw -Encoding UTF8)538539if ($response.StatusCode -eq 202) {540 $location = $response.Headers['Location']541 if ($location -is [array]) { $location = $location[0] }542 if (-not $location) { throw "LRO response missing Location header" }543 $ra = $response.Headers['Retry-After']544 if ($ra -is [array]) { $ra = $ra[0] }545 $retryAfter = if ($ra) { [int]$ra } else { 10 }546 $succeeded = $false547 for ($i = 0; $i -lt 12; $i++) {548 Start-Sleep -Seconds $retryAfter549 $poll = Invoke-RestMethod -Uri $location -Headers @{ Authorization = "Bearer $token" }550 if ($poll.status -eq 'Succeeded') { $succeeded = $true; Write-Host "Create succeeded"; break }551 elseif ($poll.status -in @('Failed', 'Cancelled')) {552 throw "Create LRO $($poll.status): $($poll.error.message)"553 }554 }555 if (-not $succeeded) { throw "Create LRO timed out" }556} else {557 Write-Host "Created: $(($response.Content | ConvertFrom-Json).displayName)"558}559```560561### Example 4: Delete an Eventstream562563**Prompt**: "Delete the SensorIngestion Eventstream from my dev workspace."564565```powershell566# 1. Discover workspace + Eventstream IDs567$wsId = (az rest --method get `568 --url "https://api.fabric.microsoft.com/v1/workspaces" `569 --resource "https://api.fabric.microsoft.com" `570 --query "value[?displayName=='dev'] | [0].id" -o tsv)571if (-not $wsId) { throw "Workspace 'dev' not found" }572573$esId = (az rest --method get `574 --url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams" `575 --resource "https://api.fabric.microsoft.com" `576 --query "value[?displayName=='SensorIngestion'] | [0].id" -o tsv)577if (-not $esId) { throw "Eventstream 'SensorIngestion' not found" }578579# 2. Delete580az rest --method delete `581 --url "https://api.fabric.microsoft.com/v1/workspaces/$wsId/eventstreams/$esId" `582 --resource "https://api.fabric.microsoft.com"583```