activator-authoring-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
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 (e.g.,
    /fabric-skills:check-updates
    ).
  • Claude Code / Cowork / Cursor / Windsurf / Codex: read the local
    package.json
    version, then compare it against the remote version via
    git fetch origin main --quiet && git show origin/main:package.json
    (or the GitHub API). If the remote version is newer, show the changelog and update instructions.
  • Skip if the check was already performed earlier in this session.
CRITICAL NOTES
  1. To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering
  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 filtering
更新检查 — 每会话一次(必填) 首次在会话中使用此技能时,请先运行check-updates技能,然后再继续。
  • GitHub Copilot CLI / VS Code:调用
    check-updates
    技能(例如:
    /fabric-skills:check-updates
    )。
  • Claude Code / Cowork / Cursor / Windsurf / Codex:读取本地
    package.json
    版本,然后通过
    git fetch origin main --quiet && git show origin/main:package.json
    (或GitHub API)与远程版本进行比较。如果远程版本更新,显示变更日志和更新说明。
  • 如果本次会话中已执行过检查,则可跳过。
重要注意事项
  1. 要通过工作区名称查找工作区详情(包括其ID):列出所有工作区,然后使用JMESPath过滤
  2. 要通过工作区ID、项类型和项名称查找项详情(包括其ID):列出该工作区中该类型的所有项,然后使用JMESPath过滤

activator-authoring-cli — Activator Item & Rule Authoring via CLI

activator-authoring-cli — 通过CLI创作Activator项与规则

Table of Contents

目录

TaskReferenceNotes
Finding Workspaces and Items in FabricCOMMON-CLI.md § Finding Workspaces and Items in FabricMandatoryREAD link first [needed for workspace/item ID resolution]
Authentication & Token AcquisitionCOMMON-CORE.md § Authentication & Token AcquisitionWrong audience = 401
Authentication RecipesCOMMON-CLI.md § Authentication RecipesUse the shared
az login
/ token guidance from common docs
Core Control-Plane REST APIsCOMMON-CORE.md § Core Control-Plane REST APIsList Workspaces, List Items, Item Creation
Long-Running Operations (LRO)COMMON-CORE.md § Long-Running Operations (LRO)Create, getDefinition, updateDefinition may return 202
Fabric Item DefinitionsITEM-DEFINITIONS-CORE.md § Definition EnvelopeBase64-encoded parts structure
Fabric Control-Plane API via
az rest
COMMON-CLI.md § Fabric Control-Plane API via az restAlways pass
--resource https://api.fabric.microsoft.com
LRO PatternCOMMON-CLI.md § Long-Running Operations (LRO) PatternPoll 202 responses
Entity Types, Sources & Viewssource-types.mdEntity envelope, source entities, and
timeSeriesView-v1
variants
Eventstream Sourceeventstream-source.mdPush-source workflow: create Eventstream sink first, then extend the discovered Activator entities
KQL Sourcekql-source.mdKQL source schema, time-axis support, design guidance
Digital Twin Builder / Ontology Sourcedtb-source.mdDTB / ontology source schema, JSON-string query payloads, snapshot vs time-axis guidance
Real-time Hub Sourcereal-time-hub-source.mdReal-time Hub source schema, workspace event types
Rule Conditionsrule-conditions.mdRule template structure, detection conditions, aggregation, time windows, occurrence options, enrichments
Action Typesaction-types.mdTeamsMessage, EmailMessage, FabricItemInvocation action schemas

任务参考文档说明
在Fabric中查找工作区和项COMMON-CLI.md § Finding Workspaces and Items in Fabric必填先阅读链接 [解析工作区/项ID所需]
身份验证与令牌获取COMMON-CORE.md § Authentication & Token Acquisition受众错误会导致401
身份验证方案COMMON-CLI.md § Authentication Recipes使用通用文档中共享的
az login
/ 令牌指南
核心控制平面REST APICOMMON-CORE.md § Core Control-Plane REST APIs列出工作区、列出项、创建项
长时间运行操作(LRO)COMMON-CORE.md § Long-Running Operations (LRO)Create、getDefinition、updateDefinition可能返回202
Fabric项定义ITEM-DEFINITIONS-CORE.md § Definition EnvelopeBase64编码的部件结构
通过
az rest
调用Fabric控制平面API
COMMON-CLI.md § Fabric Control-Plane API via az rest始终传递
--resource https://api.fabric.microsoft.com
LRO模式COMMON-CLI.md § Long-Running Operations (LRO) Pattern轮询202响应
实体类型、源与视图source-types.md实体信封、源实体和
timeSeriesView-v1
变体
Eventstream源eventstream-source.md推送源工作流:先创建Eventstream接收器,再扩展已发现的Activator实体
KQL源kql-source.mdKQL源架构、时间轴支持、设计指南
Digital Twin Builder / Ontology源dtb-source.mdDTB / Ontology源架构、JSON字符串查询负载、快照与时间轴指南
Real-time Hub源real-time-hub-source.mdReal-time Hub源架构、工作区事件类型
规则条件rule-conditions.md规则模板结构、检测条件、聚合、时间窗口、触发选项、增强功能
动作类型action-types.mdTeamsMessage、EmailMessage、FabricItemInvocation动作架构

Tool Stack

工具栈

ToolPurpose
az CLIFabric authentication and REST API token acquisition
curlHeader-aware Fabric REST calls through the shared
fabric_lro
helper
jqJSON filtering and decoded definition inspection
pythonMUST use for building ReflexEntities.json
json.dumps()
handles nested stringification correctly. PowerShell's
ConvertTo-Json
corrupts nested JSON strings.
⚠️ CRITICAL: Always use Python (not PowerShell) to build the ReflexEntities.json payload and the API request body.
工具用途
az CLIFabric身份验证与REST API令牌获取
curl通过共享的
fabric_lro
助手发起支持Header的Fabric REST调用
jqJSON过滤与解码定义检查
python必须用于构建ReflexEntities.json
json.dumps()
可正确处理嵌套字符串化。PowerShell的
ConvertTo-Json
会损坏嵌套JSON字符串。
⚠️ 重要提示:始终使用Python(而非PowerShell)构建ReflexEntities.json负载和API请求体。

Python Patterns

Python模式

python
import json, base64, uuid
python
import json, base64, uuid

Stringify template → JSON string for definition.instance

Stringify template → JSON string for definition.instance

instance_string = json.dumps(template_dict, separators=(',', ':'))
instance_string = json.dumps(template_dict, separators=(',', ':'))

Encode entities and write updateDefinition request body

Encode entities and write updateDefinition request body

payload_b64 = base64.b64encode(json.dumps(entities).encode('utf-8')).decode('utf-8') body = json.dumps({"definition": {"parts": [{"path": "ReflexEntities.json", "payload": payload_b64, "payloadType": "InlineBase64"}]}}) with open('update-body.json', 'w', encoding='utf-8') as f: f.write(body)
payload_b64 = base64.b64encode(json.dumps(entities).encode('utf-8')).decode('utf-8') body = json.dumps({"definition": {"parts": [{"path": "ReflexEntities.json", "payload": payload_b64, "payloadType": "InlineBase64"}]}}) with open('update-body.json', 'w', encoding='utf-8') as f: f.write(body)

Then: az rest --method POST --url "...updateDefinition" --resource "https://api.fabric.microsoft.com" --body @update-body.json

Then: az rest --method POST --url "...updateDefinition" --resource "https://api.fabric.microsoft.com" --body @update-body.json

Decode a getDefinition response

Decode a getDefinition response

response = json.loads(api_output) for part in response['definition']['parts']: if part['path'] == 'ReflexEntities.json': entities = json.loads(base64.b64decode(part['payload']).decode('utf-8'))
response = json.loads(api_output) for part in response['definition']['parts']: if part['path'] == 'ReflexEntities.json': entities = json.loads(base64.b64decode(part['payload']).decode('utf-8'))

Generate GUIDs for uniqueIdentifier and step id fields

Generate GUIDs for uniqueIdentifier and step id fields

entity_id = str(uuid.uuid4())

---
entity_id = str(uuid.uuid4())

---

Connection

连接

Use the shared authentication guidance in COMMON-CLI.md § Authentication Recipes. Resolve workspace and item IDs per COMMON-CLI.md § Finding Workspaces and Items in Fabric. Examples below assume
WS_ID
and
REFLEX_ID
are already resolved.

请遵循COMMON-CLI.md § Authentication Recipes中的共享身份验证指南。根据COMMON-CLI.md § Finding Workspaces and Items in Fabric解析工作区和项ID。以下示例假设已解析好
WS_ID
REFLEX_ID

Item CRUD

项CRUD操作

Use the shared mechanics in COMMON-CLI.md § Item CRUD Operations. Activator uses the
reflexes
endpoint rather than the generic
items
endpoint:
OperationEndpointMethodScopesNotes
Create
/v1/workspaces/{workspaceId}/reflexes
POST
Reflex.ReadWrite.All
or
Item.ReadWrite.All
May return 202 LRO — use
fabric_lro
from COMMON-CLI
Update metadata
/v1/workspaces/{workspaceId}/reflexes/{reflexId}
PATCH
Reflex.ReadWrite.All
or
Item.ReadWrite.All
Follow COMMON-CLI metadata update pattern
Delete
/v1/workspaces/{workspaceId}/reflexes/{reflexId}
DELETE
Reflex.ReadWrite.All
or
Item.ReadWrite.All
Add
?hardDelete=true
for permanent deletion
getDefinition
/v1/workspaces/{workspaceId}/reflexes/{reflexId}/getDefinition
POST
Reflex.ReadWrite.All
or
Item.ReadWrite.All
Empty body required; may return 202 LRO — use
fabric_lro
updateDefinition
/v1/workspaces/{workspaceId}/reflexes/{reflexId}/updateDefinition
POST
Reflex.ReadWrite.All
or
Item.ReadWrite.All
Use Python to build
update-body.json
, then follow COMMON-CLI updateDefinition pattern

使用COMMON-CLI.md § Item CRUD Operations中的共享机制。Activator使用
reflexes
端点而非通用的
items
端点:
操作端点方法权限范围说明
创建
/v1/workspaces/{workspaceId}/reflexes
POST
Reflex.ReadWrite.All
Item.ReadWrite.All
可能返回202 LRO — 使用COMMON-CLI中的
fabric_lro
更新元数据
/v1/workspaces/{workspaceId}/reflexes/{reflexId}
PATCH
Reflex.ReadWrite.All
Item.ReadWrite.All
遵循COMMON-CLI的元数据更新模式
删除
/v1/workspaces/{workspaceId}/reflexes/{reflexId}
DELETE
Reflex.ReadWrite.All
Item.ReadWrite.All
添加
?hardDelete=true
可永久删除
getDefinition
/v1/workspaces/{workspaceId}/reflexes/{reflexId}/getDefinition
POST
Reflex.ReadWrite.All
Item.ReadWrite.All
需要空请求体;可能返回202 LRO — 使用
fabric_lro
updateDefinition
/v1/workspaces/{workspaceId}/reflexes/{reflexId}/updateDefinition
POST
Reflex.ReadWrite.All
Item.ReadWrite.All
使用Python构建
update-body.json
,然后遵循COMMON-CLI的updateDefinition模式

Rule Management via Definitions

通过定义管理规则

Rules are managed through
getDefinition
and
updateDefinition
. The payload is
ReflexEntities.json
, a Base64-encoded JSON array of entity objects. Workflow: Get → Decode → Modify → Re-encode → Update.
规则通过
getDefinition
updateDefinition
进行管理。负载为
ReflexEntities.json
,是一个Base64编码的实体对象JSON数组。工作流程:获取 → 解码 → 修改 → 重新编码 → 更新

Get Definition

获取定义

getDefinition
is a POST (not GET), requires ReadWrite scopes, and may return 202 LRO. Use the
fabric_lro
helper from COMMON-CLI.md § Long-Running Operations (LRO) Pattern so 202 responses can be polled via the
Location
header before decoding.
bash
DEFINITION=$(fabric_lro POST \
  "https://api.fabric.microsoft.com/v1/workspaces/${WS_ID}/reflexes/${REFLEX_ID}/getDefinition" \
  '{}')

echo "$DEFINITION" \
  | jq '.definition.parts[] | select(.path=="ReflexEntities.json") | .payload' -r \
  | base64 -d | jq .
getDefinition
POST请求(而非GET),需要ReadWrite权限范围,可能返回202 LRO。使用COMMON-CLI.md § Long-Running Operations (LRO) Pattern中的
fabric_lro
助手,以便通过
Location
头轮询202响应后再进行解码。
bash
DEFINITION=$(fabric_lro POST \
  "https://api.fabric.microsoft.com/v1/workspaces/${WS_ID}/reflexes/${REFLEX_ID}/getDefinition" \
  '{}')

echo "$DEFINITION" \
  | jq '.definition.parts[] | select(.path=="ReflexEntities.json") | .payload' -r \
  | base64 -d | jq .

Update Definition

更新定义

MUST use Python to build
update-body.json
(see Python Patterns), then upload it using the COMMON-CLI updateDefinition pattern against
/v1/workspaces/{workspaceId}/reflexes/{reflexId}/updateDefinition
.
必须使用Python构建
update-body.json
(参见Python模式),然后针对
/v1/workspaces/{workspaceId}/reflexes/{reflexId}/updateDefinition
遵循COMMON-CLI的updateDefinition模式进行上传。

ReflexEntities.json — Assembly Procedure

ReflexEntities.json — 组装步骤

Build a JSON array of entities in order. Each needs a fresh GUID for
uniqueIdentifier
. For the hand-authored pull-source flows in this skill, use templateVersion
1.2.4
. For Eventstream sink-created flows, preserve the template version already present in the decoded Activator definition; those readbacks can use
1.1
.
Step 1 — Container (exactly 1):
  • Type:
    container-v1
    . Use the container payload type that matches the source graph:
    kqlQueries
    for KQL sources,
    rthSubscriptions
    for Real-Time Hub workspace subscriptions, or the service-created type already present in readback for Eventstream flows.
  • All other entities reference this via
    parentContainer.targetUniqueIdentifier
Step 2 — Data Source (exactly 1, pick the right type):
  • See eventstream-source.md, kql-source.md, dtb-source.md, or real-time-hub-source.md for the supported source workflows
  • For hand-authored pull sources, set
    parentContainer.targetUniqueIdentifier
    → Container GUID
  • For
    eventstreamSource-v1
    : do not start by hand-authoring the source. Create or update the Eventstream with an
    Activator
    destination first, then read the Activator definition and continue from the auto-created
    eventstreamSource-v1
    + SourceEvent entities. In public readback, those sink-created entities can appear without explicit
    parentContainer
    .
  • For
    kqlSource-v1
    : the KQL query should return ALL data (do NOT pre-filter conditions — let the rule handle that). Must include
    eventhouseItem
    ,
    metadata
    , and
    queryParameters
    . For Fabric Eventhouse/KQL DB sources, use
    eventhouseItem: { itemId, workspaceId, itemType: "KustoDatabase" }
    . For external ADX/Kusto sources, use
    eventhouseItem: { clusterHostName, databaseName }
    . Before creating the Activator, run the KQL directly against the target source first and confirm the returned columns, timestamp field, and row shape are correct. Use
    eventTimeSettings
    plus
    DURATION_START
    /
    DURATION_END
    queryParameters whenever the query results have a reasonable timestamp column, and declare those parameters in the KQL with
    declare query_parameters(startTime:datetime, endTime:datetime);
    .
    Only use snapshot mode (
    queryParameters: []
    , no
    eventTimeSettings
    , no time filtering) when the underlying data has no reasonable timestamp column and each row represents current state. See kql-source.md.
  • For
    digitalTwinBuilderSource-v1
    : use a DTB / Ontology
    connection
    item ref
    { itemId, workspaceId, itemType }
    , where
    itemType
    is either
    DigitalTwinBuilder
    or
    Ontology
    .
    query.queryString
    must be a JSON-string payload, not KQL. Before creating the Activator, run the DTB / Ontology query directly first and confirm the returned columns, key fields, and timestamp field are correct. Prefer
    eventTimeSettings
    plus
    DURATION_START
    /
    DURATION_END
    query parameters when the returned rows include a reasonable timestamp field; unlike KQL, those duration parameters are applied as DTB endpoint URL query params rather than referenced inside the query body. See dtb-source.md.
Step 3 — SourceEvent view (exactly 1):
  • Type:
    timeSeriesView-v1
    , definition.type:
    "Event"
    , instance:
    SourceEvent
    template referencing Source by
    entityId
  • For hand-authored pull-source flows, set
    parentContainer
    → Container GUID
  • For Eventstream sink-created flows, reuse the auto-created SourceEvent from readback instead of creating a second one
Step 4 — Choose the entity graph based on trigger type
  • For
    AttributeTrigger
    rules
    (thresholds, ranges, text matches, boolean checks, aggregations):
    • Create an Object view
    • Optionally create SplitEvent if events must be mapped to object instances
    • Create IdentityPartAttribute and any required BasicEventAttribute entities
    • The rule then references those value attributes in
      ScalarSelectStep
  • For
    EventTrigger
    rules
    (fire on every event, heartbeat, event field state/change):
    • Use the minimal graph: Container → Source → SourceEvent → Rule (+ optional
      fabricItemAction-v1
      )
    • Do NOT create Object, SplitEvent, IdentityPartAttribute, or BasicEventAttribute entities unless the scenario truly needs attribute-based modeling
    • EventTrigger reads raw event fields directly in
      FieldsDefaultsStep
      /
      EventDetectStep
Step 5 — Rule (1 per alert):
  • Type:
    timeSeriesView-v1
    , definition.type:
    "Rule"
  • Always add
    "description": "Created by: skills-for-fabric"
    for user clarity
  • Instance: rule template (see rule-conditions.md)
    • AttributeTrigger
      (v1.2.4): ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep
    • EventTrigger
      (v1.2.4): FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep
  • instance
    MUST be a JSON string (use
    json.dumps()
    )
  • Every template step inside
    instance.steps[]
    needs an
    id
    GUID. Missing step IDs can produce invalid expression graphs because backend translators use the step ID as the output node ID.
  • For
    AttributeTrigger
    , set
    parentObject
    → Object and
    parentContainer
    → Container
  • For
    EventTrigger
    , set
    parentContainer
    → Container and omit
    parentObject
    unless the design explicitly requires it
  • Default to
    settings: { "shouldRun": true, "shouldApplyRuleOnUpdate": false }
    so newly created rules start in the started / running state
  • Only set
    shouldRun: false
    when the user explicitly asks for a stopped rule or when a specific safe verification / eval workflow requires a disabled rule to avoid side effects
  • For
    TeamsMessage
    actions with dynamic content, preserve the field-specific reference shapes from working readback: inline mixed-content fragments in
    headline
    /
    optionalMessage
    use
    AttributeReference
    with
    type: "complex"
    , while structured
    additionalInformation
    entries use
    NameReferencePair
    +
    AttributeReference
    /
    EventFieldReference
    with
    type: "complexReference"
    and
    name: "reference"
Example rule entity:
python
{
    "uniqueIdentifier": "<rule-guid>",
    "payload": {
        "name": "My Rule Name",
        "description": "Created by: skills-for-fabric",  # Required for user clarity
        "parentObject": {"targetUniqueIdentifier": "<object-guid>"},
        "parentContainer": {"targetUniqueIdentifier": "<container-guid>"},
        "definition": {
            "type": "Rule",
            "instance": stringify_instance(rule_template),
            "settings": {"shouldRun": True, "shouldApplyRuleOnUpdate": False}
        }
    },
    "type": "timeSeriesView-v1"
}
Step 6 — Fabric Item Action (only for
FabricItemInvocation
):
  • Type:
    fabricItemAction-v1
    — use this standalone action entity whenever the rule invokes a Fabric item such as a Pipeline, Notebook, Spark job definition, Dataflow, or UDF / Function Set
  • See action-types.md for schema
  • In the rule's
    FabricItemBinding
    , set
    fabricJobConnectionDocumentId
    to the standalone
    fabricItemAction-v1.uniqueIdentifier
    ; this is the expected linkage between the binding row and the action entity.
  • For UDF / function-set actions, author the rule binding with
    itemType: "UserDataFunctions"
    . On later
    getDefinition
    readback, the standalone
    fabricItemAction-v1
    entity may surface
    payload.fabricItem.itemType: "FunctionSet"
    while the embedded
    FabricItemBinding
    still shows
    UserDataFunctions
    .
  • For UDF / function-set actions, verify the target item actually exposes a non-empty function list and set
    subitemId
    to the discovered function name. Parameter names and
    parameterType
    values must match the discovered Fabric function metadata exactly; omit parameters that are not exposed by the target function. If the target item has no registered functions, the Activator linkage is incomplete and the action should not be treated as valid.
按顺序构建实体JSON数组。每个实体需要为
uniqueIdentifier
生成新的GUID。对于本技能中手动编写的拉取源流,使用templateVersion
1.2.4
。对于Eventstream接收器创建的流,保留解码后的Activator定义中已有的模板版本;这些回读的流可使用
1.1
版本。
步骤1 — 容器(恰好1个):
  • 类型:
    container-v1
    。使用与源图匹配的容器负载类型:KQL源使用
    kqlQueries
    ,Real-Time Hub工作区订阅使用
    rthSubscriptions
    ,Eventstream流使用回读中已有的服务创建类型。
  • 所有其他实体通过
    parentContainer.targetUniqueIdentifier
    引用此容器
步骤2 — 数据源(恰好1个,选择正确类型):
  • 请参阅eventstream-source.mdkql-source.mddtb-source.mdreal-time-hub-source.md获取支持的源工作流
  • 对于手动编写的拉取源,设置
    parentContainer.targetUniqueIdentifier
    → 容器GUID
  • 对于
    eventstreamSource-v1
    :不要手动编写源。先创建或更新带有
    Activator
    目标的Eventstream,然后读取Activator定义并从自动创建的
    eventstreamSource-v1
    + SourceEvent实体继续操作。在公开回读中,这些接收器创建的实体可能无需显式
    parentContainer
    即可显示。
  • 对于
    kqlSource-v1
    :KQL查询应返回所有数据(不要预先过滤条件 — 让Activator规则步骤处理)。必须包含
    eventhouseItem
    metadata
    queryParameters
    。对于Fabric Eventhouse/KQL DB源,使用
    eventhouseItem: { itemId, workspaceId, itemType: "KustoDatabase" }
    。对于外部ADX/Kusto源,使用
    eventhouseItem: { clusterHostName, databaseName }
    创建Activator之前,请直接针对目标源运行KQL并确认返回的列、时间戳字段和行结构正确。 只要查询结果有合理的时间戳列,就使用
    eventTimeSettings
    加上
    DURATION_START
    /
    DURATION_END
    queryParameters,并在KQL中用
    declare query_parameters(startTime:datetime, endTime:datetime);
    声明这些参数。
    仅当底层数据没有合理的时间戳列且每行代表当前状态时,才使用快照模式(
    queryParameters: []
    ,无
    eventTimeSettings
    ,无时间过滤)。请参阅kql-source.md
  • 对于
    digitalTwinBuilderSource-v1
    :使用DTB / Ontology
    connection
    项引用
    { itemId, workspaceId, itemType }
    ,其中
    itemType
    DigitalTwinBuilder
    Ontology
    query.queryString
    必须是JSON字符串负载,而非KQL。创建Activator之前,请直接运行DTB / Ontology查询并确认返回的列、关键字段和时间戳字段正确。 当返回的行包含合理的时间戳字段时,优先使用
    eventTimeSettings
    加上
    DURATION_START
    /
    DURATION_END
    查询参数;与KQL不同,这些持续时间参数作为DTB端点URL查询参数应用,而非在查询体内部引用。请参阅dtb-source.md
步骤3 — SourceEvent视图(恰好1个):
  • 类型:
    timeSeriesView-v1
    ,definition.type:
    "Event"
    ,instance: 通过
    entityId
    引用源的SourceEvent模板
  • 对于手动编写的拉取源流,设置
    parentContainer
    → 容器GUID
  • 对于Eventstream接收器创建的流,重用回读中自动创建的SourceEvent,而非创建第二个
步骤4 — 根据触发器类型选择实体图
  • 对于
    AttributeTrigger
    规则
    (阈值、范围、文本匹配、布尔检查、聚合):
    • 创建一个Object视图
    • 如果事件必须映射到对象实例,可选择创建SplitEvent
    • 创建IdentityPartAttribute和任何所需的BasicEventAttribute实体
    • 规则随后在
      ScalarSelectStep
      中引用这些值属性
  • 对于
    EventTrigger
    规则
    (每个事件触发、心跳、事件字段状态/变化):
    • 使用最小图:Container → Source → SourceEvent → Rule(+ 可选
      fabricItemAction-v1
    • 除非场景确实需要基于属性的建模,否则不要创建Object、SplitEvent、IdentityPartAttribute或BasicEventAttribute实体
    • EventTrigger直接在
      FieldsDefaultsStep
      /
      EventDetectStep
      中读取原始事件字段
步骤5 — 规则(每个告警1个):
  • 类型:
    timeSeriesView-v1
    ,definition.type:
    "Rule"
  • 始终添加
    "description": "Created by: skills-for-fabric"
    ,方便用户识别
  • Instance: 规则模板(参见rule-conditions.md
    • AttributeTrigger
      (v1.2.4):ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep
    • EventTrigger
      (v1.2.4):FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep
  • instance
    必须是JSON字符串(使用
    json.dumps()
  • instance.steps[]
    内的每个模板步骤都需要一个
    id
    GUID。缺少步骤ID会导致表达式图无效,因为后端转换器使用步骤ID作为输出节点ID。
  • 对于
    AttributeTrigger
    ,设置
    parentObject
    → Object和
    parentContainer
    → Container
  • 对于
    EventTrigger
    ,设置
    parentContainer
    → Container,除非设计明确要求,否则省略
    parentObject
  • 默认使用
    settings: { "shouldRun": true, "shouldApplyRuleOnUpdate": false }
    ,使新创建的规则处于启动/运行状态
  • 仅当用户明确要求停止规则,或特定安全验证/评估工作流需要禁用规则以避免副作用时,才设置
    shouldRun: false
  • 对于带有动态内容的
    TeamsMessage
    动作,保留有效回读中的字段特定引用格式:
    headline
    /
    optionalMessage
    中的内联混合内容片段使用
    AttributeReference
    type: "complex"
    ,而结构化
    additionalInformation
    条目使用
    NameReferencePair
    +
    AttributeReference
    /
    EventFieldReference
    type: "complexReference"
    name: "reference"
示例规则实体:
python
{
    "uniqueIdentifier": "<rule-guid>",
    "payload": {
        "name": "My Rule Name",
        "description": "Created by: skills-for-fabric",  # Required for user clarity
        "parentObject": {"targetUniqueIdentifier": "<object-guid>"},
        "parentContainer": {"targetUniqueIdentifier": "<container-guid>"},
        "definition": {
            "type": "Rule",
            "instance": stringify_instance(rule_template),
            "settings": {"shouldRun": True, "shouldApplyRuleOnUpdate": False}
        }
    },
    "type": "timeSeriesView-v1"
}
步骤6 — Fabric项动作(仅适用于
FabricItemInvocation
):
  • 类型:
    fabricItemAction-v1
    — 当规则调用Fabric项(如Pipeline、Notebook、Spark作业定义、Dataflow或UDF / Function Set)时,使用此独立动作实体
  • 请参阅action-types.md获取架构
  • 在规则的
    FabricItemBinding
    中,将
    fabricJobConnectionDocumentId
    设置为独立
    fabricItemAction-v1.uniqueIdentifier
    ;这是绑定行与动作实体之间的预期关联方式。
  • 对于UDF / 函数集动作,编写规则绑定并设置
    itemType: "UserDataFunctions"
    。在后续
    getDefinition
    回读中,独立
    fabricItemAction-v1
    实体可能显示
    payload.fabricItem.itemType: "FunctionSet"
    ,而嵌入式
    FabricItemBinding
    仍显示
    UserDataFunctions
  • 对于UDF / 函数集动作,验证目标项是否实际公开非空函数列表,并将
    subitemId
    设置为发现的函数名称。参数名称和
    parameterType
    值必须与发现的Fabric函数元数据完全匹配;省略目标函数未公开的参数。如果目标项没有注册函数,则Activator关联不完整,该动作不应视为有效。

Entity Wiring Summary

实体连接总结

text
Container ← everything references this via parentContainer
    ├── Source ← parentContainer → Container
    ├── SourceEvent ← parentContainer → Container
    │        │         instance references Source by entityId
    │        │
    │        ├── EventTrigger Rule ← parentContainer → Container
    │        │       minimal event-only path; reads raw event fields directly
    │        │
    │        └── Object ← parentContainer → Container
    │              │
    │              ├── (SplitEvent) ← OPTIONAL, parentObject → Object, parentContainer → Container
    │              │       instance references SourceEvent by entityId
    │              │       maps events to objects via FieldIdMapping
    │              │
    │              ├── Identity Attr ← parentObject → Object, parentContainer → Container
    │              │
    │              ├── Value Attr(s) ← parentObject → Object, parentContainer → Container
    │              │       instance references SourceEvent (or SplitEvent if used) by entityId
    │              │
    │              └── AttributeTrigger Rule ← parentObject → Object, parentContainer → Container
    │                      instance references Value Attr by entityId in ScalarSelectStep
    └── (FabricItemAction) ← parentContainer → Container (for any FabricItemInvocation action: Pipeline, Notebook, Spark job, Dataflow, or UDF / Function Set)
text
Container ← everything references this via parentContainer
    ├── Source ← parentContainer → Container
    ├── SourceEvent ← parentContainer → Container
    │        │         instance references Source by entityId
    │        │
    │        ├── EventTrigger Rule ← parentContainer → Container
    │        │       minimal event-only path; reads raw event fields directly
    │        │
    │        └── Object ← parentContainer → Container
    │              │
    │              ├── (SplitEvent) ← OPTIONAL, parentObject → Object, parentContainer → Container
    │              │       instance references SourceEvent by entityId
    │              │       maps events to objects via FieldIdMapping
    │              │
    │              ├── Identity Attr ← parentObject → Object, parentContainer → Container
    │              │
    │              ├── Value Attr(s) ← parentObject → Object, parentContainer → Container
    │              │       instance references SourceEvent (or SplitEvent if used) by entityId
    │              │
    │              └── AttributeTrigger Rule ← parentObject → Object, parentContainer → Container
    │                      instance references Value Attr by entityId in ScalarSelectStep
    └── (FabricItemAction) ← parentContainer → Container (for any FabricItemInvocation action: Pipeline, Notebook, Spark job, Dataflow, or UDF / Function Set)

Critical:
definition.instance
is a JSON String

重要提示:
definition.instance
是JSON字符串

instance
inside
timeSeriesView-v1
entity's
definition
is a JSON-encoded string, not a nested object. Always wrap rule templates in the full entity envelope.
❌ WRONG — raw template object (will fail):
json
{
  "templateId": "AttributeTrigger",
  "templateVersion": "1.2.4",
  "steps": [...]
}
✅ CORRECT — entity envelope with stringified instance:
json
{
  "uniqueIdentifier": "<new-guid>",
  "payload": {
    "name": "My Rule Name",
    "parentObject": { "targetUniqueIdentifier": "<object-guid>" },
      "parentContainer": { "targetUniqueIdentifier": "<container-guid>" },
      "definition": {
        "type": "Rule",
        "instance": "{\"templateId\":\"AttributeTrigger\",\"templateVersion\":\"1.2.4\",\"steps\":[...]}",
        "settings": { "shouldRun": true, "shouldApplyRuleOnUpdate": false }
      }
    },
    "type": "timeSeriesView-v1"
}
Use
json.dumps()
to stringify. Do NOT use PowerShell's
ConvertTo-Json
.
timeSeriesView-v1
实体的
definition
中的
instance
JSON编码字符串,而非嵌套对象。始终将规则模板包装在完整的实体信封中。
❌ 错误 — 原始模板对象(会失败):
json
{
  "templateId": "AttributeTrigger",
  "templateVersion": "1.2.4",
  "steps": [...]
}
✅ 正确 — 带有字符串化instance的实体信封:
json
{
  "uniqueIdentifier": "<new-guid>",
  "payload": {
    "name": "My Rule Name",
    "parentObject": { "targetUniqueIdentifier": "<object-guid>" },
      "parentContainer": { "targetUniqueIdentifier": "<container-guid>" },
      "definition": {
        "type": "Rule",
        "instance": "{\"templateId\":\"AttributeTrigger\",\"templateVersion\":\"1.2.4\",\"steps\":[...]}",
        "settings": { "shouldRun": true, "shouldApplyRuleOnUpdate": false }
      }
    },
    "type": "timeSeriesView-v1"
}
使用
json.dumps()
进行字符串化。不要使用PowerShell的
ConvertTo-Json

Two Rule Template Types

两种规则模板类型

TemplateWhen to UseSteps
AttributeTrigger
Monitor attribute value (numeric, text, boolean)ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep
EventTrigger
Fire on event occurrence (state, change, heartbeat)FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep
EventTrigger does NOT have ScalarSelectStep/ScalarDetectStep. Use when acting on events directly. Supports state, change, and heartbeat detection via EventDetectStep.

模板使用场景步骤
AttributeTrigger
监控属性值(数值、文本、布尔值)ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep
EventTrigger
事件发生时触发(状态、变化、心跳)FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep
EventTrigger 没有ScalarSelectStep/ScalarDetectStep。直接对事件执行动作时使用。支持通过EventDetectStep进行状态、变化和心跳检测。

Must / Prefer / Avoid

必须做/推荐做/避免做

MUST DO

必须做

  • Always use
    --resource https://api.fabric.microsoft.com
    with
    az rest
    — without it, token audience is wrong
  • Always send
    --body '{}'
    for
    getDefinition
    — it is a POST and omitting the body can cause 411 errors
  • Always Base64-encode
    ReflexEntities.json
    payload when calling
    updateDefinition
  • Always JSON.stringify the
    definition.instance
    field in
    timeSeriesView-v1
    entities — it must be a string, not a nested object. Always wrap rule templates in the full entity envelope (see the ❌/✅ example above) — never output a raw template object without the entity wrapper
  • Always use the correct template type
    AttributeTrigger
    for value-based conditions (has ScalarSelectStep + ScalarDetectStep),
    EventTrigger
    for event-based firing (has FieldsDefaultsStep + EventDetectStep, no ScalarDetectStep)
  • Always use new GUIDs for
    uniqueIdentifier
    when adding entities — duplicate GUIDs cause corruption
  • Always update all cross-references when changing a
    uniqueIdentifier
    — other entities reference it via
    targetUniqueIdentifier
  • Handle LRO responses
    create
    ,
    getDefinition
    , and
    updateDefinition
    may return 202; poll the
    Location
    header
  • 使用
    az rest
    时始终传递
    --resource https://api.fabric.microsoft.com
    — 缺少此参数会导致令牌受众错误
  • 调用
    getDefinition
    时始终发送
    --body '{}'
    — 这是POST请求,省略请求体可能导致411错误
  • 调用
    updateDefinition
    时始终对
    ReflexEntities.json
    负载进行Base64编码
  • 始终对
    timeSeriesView-v1
    实体的
    definition.instance
    字段进行JSON.stringify
    — 它必须是字符串,而非嵌套对象。始终将规则模板包装在完整的实体信封中(参见上面的❌/✅示例) — 永远不要输出没有实体包装的原始模板对象
  • 始终使用正确的模板类型
    AttributeTrigger
    用于基于值的条件(包含ScalarSelectStep + ScalarDetectStep),
    EventTrigger
    用于基于事件的触发(包含FieldsDefaultsStep + EventDetectStep,无ScalarDetectStep)
  • 添加实体时始终使用新的GUID作为
    uniqueIdentifier
    — 重复的GUID会导致损坏
  • 修改
    uniqueIdentifier
    时始终更新所有交叉引用
    — 其他实体通过
    targetUniqueIdentifier
    引用它
  • 处理LRO响应
    create
    getDefinition
    updateDefinition
    可能返回202;轮询
    Location

PREFER

推荐做

  • Read-modify-write over full replacement — get the current definition, modify the entity array, and update
  • Soft delete over hard delete unless permanent removal is intended
  • Discover IDs dynamically via workspace listing + JMESPath rather than hardcoding GUIDs
  • Transition-based alert conditions over steady-state conditions for most alerts — prefer detectors such as
    NumberBecomes
    ,
    NumberEntersOrLeavesRange
    ,
    LogicalBecomes
    , or explicit change conditions even when the user says casual state-like wording such as "is greater than", "is below", or "is outside the range". Treat ordinary alert wording as "notify me when it crosses into that state" to avoid repeated notifications while the condition remains true
  • Steady-state conditions such as
    IsGreaterThan
    ,
    IsLessThan
    , or
    IsOutsideRange
    only when the user explicitly asks for repeated firing while the value stays in the triggered state, for example "notify me every time it is greater than 30", "fire on every evaluation while it is above 30", or when a downstream occurrence / windowing pattern truly depends on that semantics
  • 优先使用读取-修改-写入而非完全替换 — 获取当前定义,修改实体数组,然后更新
  • 优先使用软删除而非硬删除,除非需要永久移除
  • 通过工作区列表 + JMESPath动态发现ID,而非硬编码GUID
  • 对于大多数告警,优先使用基于转换的告警条件而非稳态条件 — 即使用户使用类似"大于"、"低于"或"超出范围"的常规状态表述,也优先使用
    NumberBecomes
    NumberEntersOrLeavesRange
    LogicalBecomes
    等检测器或显式变化条件。将普通告警表述视为"当它进入该状态时通知我",以避免条件持续成立时重复通知
  • 仅当用户明确要求在值保持触发状态时重复触发,例如"每次大于30时通知我"、"每次评估时只要高于30就触发",或者下游触发/窗口模式确实依赖该语义时,才使用
    IsGreaterThan
    IsLessThan
    IsOutsideRange
    等稳态条件

AVOID

避免做

  • Hardcoded workspace or item IDs — always resolve dynamically
  • Forgetting the
    .platform
    part
    — only include it with
    updateDefinition
    when using
    ?updateMetadata=true
  • SELECT * without filtering on list endpoints — use pagination for large workspaces
  • Modifying definitions of items with encrypted sensitivity labels
    getDefinition
    is blocked
  • Pre-filtering conditions in the KQL query — return all data from KQL and let the Activator rule steps handle thresholds, text conditions, and dimensional filters. KQL is the data source, not the rule engine
  • Inline JSON in PowerShell
    az rest --body
    — PowerShell mangles quotes and special characters. Always write JSON to a temp file with
    [System.IO.File]::WriteAllText($path, $json, [System.Text.UTF8Encoding]::new($false))
    and pass
    --body @$path
  • Reusing display names after deletion — soft-deleted items hold their name for several minutes. Use a unique name or hard-delete first

  • 硬编码工作区或项ID — 始终动态解析
  • 忘记
    .platform
    部分
    — 仅当使用
    ?updateMetadata=true
    时,才在
    updateDefinition
    中包含它
  • *在列表端点使用SELECT 而不过滤 — 大型工作区使用分页
  • 修改带有加密敏感标签的项的定义
    getDefinition
    会被阻止
  • 在KQL查询中预先过滤条件 — 从KQL返回所有数据,让Activator规则步骤处理阈值、文本条件和维度过滤。KQL是数据源,而非规则引擎
  • 在PowerShell的
    az rest --body
    中使用内联JSON
    — PowerShell会破坏引号和特殊字符。始终使用
    [System.IO.File]::WriteAllText($path, $json, [System.Text.UTF8Encoding]::new($false))
    将JSON写入临时文件,然后传递
    --body @$path
  • 删除后重用显示名称 — 软删除的项会保留其名称数分钟。使用唯一名称或先硬删除

Examples

示例

Follow the Assembly Procedure to build definitions. See reference docs for complete entity schemas: source-types.md, rule-conditions.md, action-types.md.

遵循组装步骤构建定义。请参阅参考文档获取完整实体架构:source-types.mdrule-conditions.mdaction-types.md

Agent Integration Notes

Agent集成说明

  • This skill uses the Fabric Items API (
    /reflexes
    ) for CRUD and the Definition API for rule management
  • No additional data-plane protocols are needed — all operations use
    az rest
    with the Fabric API audience
  • For reading Activator items and rules without modifying them, use the activator-consumption-cli skill instead
  • 此技能使用Fabric项API (
    /reflexes
    )进行CRUD操作,使用定义API进行规则管理
  • 无需额外的数据平面协议 — 所有操作使用带有Fabric API受众的
    az rest
  • 如果仅需读取Activator项和规则而不修改,请改用activator-consumption-cli技能