activator-authoring-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUpdate 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
skill (e.g.,check-updates)./fabric-skills:check-updates- Claude Code / Cowork / Cursor / Windsurf / Codex: read the local
version, then compare it against the remote version viapackage.json(or the GitHub API). If the remote version is newer, show the changelog and update instructions.git fetch origin main --quiet && git show origin/main:package.json- 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
更新检查 — 每会话一次(必填) 首次在会话中使用此技能时,请先运行check-updates技能,然后再继续。
- GitHub Copilot CLI / VS Code:调用
技能(例如:check-updates)。/fabric-skills:check-updates- Claude Code / Cowork / Cursor / Windsurf / Codex:读取本地
版本,然后通过package.json(或GitHub API)与远程版本进行比较。如果远程版本更新,显示变更日志和更新说明。git fetch origin main --quiet && git show origin/main:package.json- 如果本次会话中已执行过检查,则可跳过。
重要注意事项
- 要通过工作区名称查找工作区详情(包括其ID):列出所有工作区,然后使用JMESPath过滤
- 要通过工作区ID、项类型和项名称查找项详情(包括其ID):列出该工作区中该类型的所有项,然后使用JMESPath过滤
activator-authoring-cli — Activator Item & Rule Authoring via CLI
activator-authoring-cli — 通过CLI创作Activator项与规则
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 workspace/item ID resolution] |
| Authentication & Token Acquisition | COMMON-CORE.md § Authentication & Token Acquisition | Wrong audience = 401 |
| Authentication Recipes | COMMON-CLI.md § Authentication Recipes | Use the shared |
| Core Control-Plane REST APIs | COMMON-CORE.md § Core Control-Plane REST APIs | List Workspaces, List Items, Item Creation |
| Long-Running Operations (LRO) | COMMON-CORE.md § Long-Running Operations (LRO) | Create, getDefinition, updateDefinition may return 202 |
| Fabric Item Definitions | ITEM-DEFINITIONS-CORE.md § Definition Envelope | Base64-encoded parts structure |
Fabric Control-Plane API via | COMMON-CLI.md § Fabric Control-Plane API via az rest | Always pass |
| LRO Pattern | COMMON-CLI.md § Long-Running Operations (LRO) Pattern | Poll 202 responses |
| Entity Types, Sources & Views | source-types.md | Entity envelope, source entities, and |
| Eventstream Source | eventstream-source.md | Push-source workflow: create Eventstream sink first, then extend the discovered Activator entities |
| KQL Source | kql-source.md | KQL source schema, time-axis support, design guidance |
| Digital Twin Builder / Ontology Source | dtb-source.md | DTB / ontology source schema, JSON-string query payloads, snapshot vs time-axis guidance |
| Real-time Hub Source | real-time-hub-source.md | Real-time Hub source schema, workspace event types |
| Rule Conditions | rule-conditions.md | Rule template structure, detection conditions, aggregation, time windows, occurrence options, enrichments |
| Action Types | action-types.md | TeamsMessage, 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 | 使用通用文档中共享的 |
| 核心控制平面REST API | COMMON-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 Envelope | Base64编码的部件结构 |
通过 | COMMON-CLI.md § Fabric Control-Plane API via az rest | 始终传递 |
| LRO模式 | COMMON-CLI.md § Long-Running Operations (LRO) Pattern | 轮询202响应 |
| 实体类型、源与视图 | source-types.md | 实体信封、源实体和 |
| Eventstream源 | eventstream-source.md | 推送源工作流:先创建Eventstream接收器,再扩展已发现的Activator实体 |
| KQL源 | kql-source.md | KQL源架构、时间轴支持、设计指南 |
| Digital Twin Builder / Ontology源 | dtb-source.md | DTB / Ontology源架构、JSON字符串查询负载、快照与时间轴指南 |
| Real-time Hub源 | real-time-hub-source.md | Real-time Hub源架构、工作区事件类型 |
| 规则条件 | rule-conditions.md | 规则模板结构、检测条件、聚合、时间窗口、触发选项、增强功能 |
| 动作类型 | action-types.md | TeamsMessage、EmailMessage、FabricItemInvocation动作架构 |
Tool Stack
工具栈
| Tool | Purpose |
|---|---|
| az CLI | Fabric authentication and REST API token acquisition |
| curl | Header-aware Fabric REST calls through the shared |
| jq | JSON filtering and decoded definition inspection |
| python | MUST use for building ReflexEntities.json — |
⚠️ CRITICAL: Always use Python (not PowerShell) to build the ReflexEntities.json payload and the API request body.
| 工具 | 用途 |
|---|---|
| az CLI | Fabric身份验证与REST API令牌获取 |
| curl | 通过共享的 |
| jq | JSON过滤与解码定义检查 |
| python | 必须用于构建ReflexEntities.json — |
⚠️ 重要提示:始终使用Python(而非PowerShell)构建ReflexEntities.json负载和API请求体。
Python Patterns
Python模式
python
import json, base64, uuidpython
import json, base64, uuidStringify 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 and are already resolved.
WS_IDREFLEX_ID请遵循COMMON-CLI.md § Authentication Recipes中的共享身份验证指南。根据COMMON-CLI.md § Finding Workspaces and Items in Fabric解析工作区和项ID。以下示例假设已解析好和。
WS_IDREFLEX_IDItem CRUD
项CRUD操作
Use the shared mechanics in COMMON-CLI.md § Item CRUD Operations. Activator uses the endpoint rather than the generic endpoint:
reflexesitems| Operation | Endpoint | Method | Scopes | Notes |
|---|---|---|---|---|
| Create | | POST | | May return 202 LRO — use |
| Update metadata | | PATCH | | Follow COMMON-CLI metadata update pattern |
| Delete | | DELETE | | Add |
| | POST | | Empty body required; may return 202 LRO — use |
| | POST | | Use Python to build |
使用COMMON-CLI.md § Item CRUD Operations中的共享机制。Activator使用端点而非通用的端点:
reflexesitems| 操作 | 端点 | 方法 | 权限范围 | 说明 |
|---|---|---|---|---|
| 创建 | | POST | | 可能返回202 LRO — 使用COMMON-CLI中的 |
| 更新元数据 | | PATCH | | 遵循COMMON-CLI的元数据更新模式 |
| 删除 | | DELETE | | 添加 |
| | POST | | 需要空请求体;可能返回202 LRO — 使用 |
| | POST | | 使用Python构建 |
Rule Management via Definitions
通过定义管理规则
Rules are managed through and . The payload is , a Base64-encoded JSON array of entity objects. Workflow: Get → Decode → Modify → Re-encode → Update.
getDefinitionupdateDefinitionReflexEntities.json规则通过和进行管理。负载为,是一个Base64编码的实体对象JSON数组。工作流程:获取 → 解码 → 修改 → 重新编码 → 更新。
getDefinitionupdateDefinitionReflexEntities.jsonGet Definition
获取定义
is a POST (not GET), requires ReadWrite scopes, and may return 202 LRO. Use thegetDefinitionhelper from COMMON-CLI.md § Long-Running Operations (LRO) Pattern so 202 responses can be polled via thefabric_lroheader before decoding.Location
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 .是POST请求(而非GET),需要ReadWrite权限范围,可能返回202 LRO。使用COMMON-CLI.md § Long-Running Operations (LRO) Pattern中的getDefinition助手,以便通过fabric_lro头轮询202响应后再进行解码。Location
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(see Python Patterns), then upload it using the COMMON-CLI updateDefinition pattern againstupdate-body.json./v1/workspaces/{workspaceId}/reflexes/{reflexId}/updateDefinition
必须使用Python构建(参见Python模式),然后针对update-body.json遵循COMMON-CLI的updateDefinition模式进行上传。/v1/workspaces/{workspaceId}/reflexes/{reflexId}/updateDefinition
ReflexEntities.json — Assembly Procedure
ReflexEntities.json — 组装步骤
Build a JSON array of entities in order. Each needs a fresh GUID for . For the hand-authored pull-source flows in this skill, use templateVersion . For Eventstream sink-created flows, preserve the template version already present in the decoded Activator definition; those readbacks can use .
uniqueIdentifier1.2.41.1Step 1 — Container (exactly 1):
- Type: . Use the container payload type that matches the source graph:
container-v1for KQL sources,kqlQueriesfor Real-Time Hub workspace subscriptions, or the service-created type already present in readback for Eventstream flows.rthSubscriptions - 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 → Container GUID
parentContainer.targetUniqueIdentifier - For : do not start by hand-authoring the source. Create or update the Eventstream with an
eventstreamSource-v1destination first, then read the Activator definition and continue from the auto-createdActivator+ SourceEvent entities. In public readback, those sink-created entities can appear without expliciteventstreamSource-v1.parentContainer - For : the KQL query should return ALL data (do NOT pre-filter conditions — let the rule handle that). Must include
kqlSource-v1,eventhouseItem, andmetadata. For Fabric Eventhouse/KQL DB sources, usequeryParameters. For external ADX/Kusto sources, useeventhouseItem: { itemId, workspaceId, itemType: "KustoDatabase" }. 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. UseeventhouseItem: { clusterHostName, databaseName }pluseventTimeSettings/DURATION_STARTqueryParameters whenever the query results have a reasonable timestamp column, and declare those parameters in the KQL withDURATION_END. Only use snapshot mode (declare query_parameters(startTime:datetime, endTime:datetime);, noqueryParameters: [], no time filtering) when the underlying data has no reasonable timestamp column and each row represents current state. See kql-source.md.eventTimeSettings - For : use a DTB / Ontology
digitalTwinBuilderSource-v1item refconnection, where{ itemId, workspaceId, itemType }is eitheritemTypeorDigitalTwinBuilder.Ontologymust 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. Preferquery.queryStringpluseventTimeSettings/DURATION_STARTquery 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.DURATION_END
Step 3 — SourceEvent view (exactly 1):
- Type: , definition.type:
timeSeriesView-v1, instance:"Event"template referencing Source bySourceEvententityId - For hand-authored pull-source flows, set → Container GUID
parentContainer - 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
-
Forrules (thresholds, ranges, text matches, boolean checks, aggregations):
AttributeTrigger- 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
-
Forrules (fire on every event, heartbeat, event field state/change):
EventTrigger- 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 /
FieldsDefaultsStepEventDetectStep
- Use the minimal graph: Container → Source → SourceEvent → Rule (+ optional
Step 5 — Rule (1 per alert):
- Type: , definition.type:
timeSeriesView-v1"Rule" - Always add for user clarity
"description": "Created by: skills-for-fabric" - Instance: rule template (see rule-conditions.md)
- (v1.2.4): ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep
AttributeTrigger - (v1.2.4): FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep
EventTrigger
- MUST be a JSON string (use
instance)json.dumps() - Every template step inside needs an
instance.steps[]GUID. Missing step IDs can produce invalid expression graphs because backend translators use the step ID as the output node ID.id - For , set
AttributeTrigger→ Object andparentObject→ ContainerparentContainer - For , set
EventTrigger→ Container and omitparentContainerunless the design explicitly requires itparentObject - Default to so newly created rules start in the started / running state
settings: { "shouldRun": true, "shouldApplyRuleOnUpdate": false } - Only set 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
shouldRun: false - For actions with dynamic content, preserve the field-specific reference shapes from working readback: inline mixed-content fragments in
TeamsMessage/headlineuseoptionalMessagewithAttributeReference, while structuredtype: "complex"entries useadditionalInformation+NameReferencePair/AttributeReferencewithEventFieldReferenceandtype: "complexReference"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: — 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
fabricItemAction-v1 - See action-types.md for schema
- In the rule's , set
FabricItemBindingto the standalonefabricJobConnectionDocumentId; this is the expected linkage between the binding row and the action entity.fabricItemAction-v1.uniqueIdentifier - For UDF / function-set actions, author the rule binding with . On later
itemType: "UserDataFunctions"readback, the standalonegetDefinitionentity may surfacefabricItemAction-v1while the embeddedpayload.fabricItem.itemType: "FunctionSet"still showsFabricItemBinding.UserDataFunctions - For UDF / function-set actions, verify the target item actually exposes a non-empty function list and set to the discovered function name. Parameter names and
subitemIdvalues 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.parameterType
按顺序构建实体JSON数组。每个实体需要为生成新的GUID。对于本技能中手动编写的拉取源流,使用templateVersion 。对于Eventstream接收器创建的流,保留解码后的Activator定义中已有的模板版本;这些回读的流可使用版本。
uniqueIdentifier1.2.41.1步骤1 — 容器(恰好1个):
- 类型:。使用与源图匹配的容器负载类型:KQL源使用
container-v1,Real-Time Hub工作区订阅使用kqlQueries,Eventstream流使用回读中已有的服务创建类型。rthSubscriptions - 所有其他实体通过引用此容器
parentContainer.targetUniqueIdentifier
步骤2 — 数据源(恰好1个,选择正确类型):
- 请参阅eventstream-source.md、kql-source.md、dtb-source.md或real-time-hub-source.md获取支持的源工作流
- 对于手动编写的拉取源,设置→ 容器GUID
parentContainer.targetUniqueIdentifier - 对于:不要手动编写源。先创建或更新带有
eventstreamSource-v1目标的Eventstream,然后读取Activator定义并从自动创建的Activator+ SourceEvent实体继续操作。在公开回读中,这些接收器创建的实体可能无需显式eventstreamSource-v1即可显示。parentContainer - 对于:KQL查询应返回所有数据(不要预先过滤条件 — 让Activator规则步骤处理)。必须包含
kqlSource-v1、eventhouseItem和metadata。对于Fabric Eventhouse/KQL DB源,使用queryParameters。对于外部ADX/Kusto源,使用eventhouseItem: { itemId, workspaceId, itemType: "KustoDatabase" }。创建Activator之前,请直接针对目标源运行KQL并确认返回的列、时间戳字段和行结构正确。 只要查询结果有合理的时间戳列,就使用eventhouseItem: { clusterHostName, databaseName }加上eventTimeSettings/DURATION_STARTqueryParameters,并在KQL中用DURATION_END声明这些参数。 仅当底层数据没有合理的时间戳列且每行代表当前状态时,才使用快照模式(declare query_parameters(startTime:datetime, endTime:datetime);,无queryParameters: [],无时间过滤)。请参阅kql-source.md。eventTimeSettings - 对于:使用DTB / Ontology
digitalTwinBuilderSource-v1项引用connection,其中{ itemId, workspaceId, itemType }为itemType或DigitalTwinBuilder。Ontology必须是JSON字符串负载,而非KQL。创建Activator之前,请直接运行DTB / Ontology查询并确认返回的列、关键字段和时间戳字段正确。 当返回的行包含合理的时间戳字段时,优先使用query.queryString加上eventTimeSettings/DURATION_START查询参数;与KQL不同,这些持续时间参数作为DTB端点URL查询参数应用,而非在查询体内部引用。请参阅dtb-source.md。DURATION_END
步骤3 — SourceEvent视图(恰好1个):
- 类型:,definition.type:
timeSeriesView-v1,instance: 通过"Event"引用源的SourceEvent模板entityId - 对于手动编写的拉取源流,设置→ 容器GUID
parentContainer - 对于Eventstream接收器创建的流,重用回读中自动创建的SourceEvent,而非创建第二个
步骤4 — 根据触发器类型选择实体图
-
对于规则(阈值、范围、文本匹配、布尔检查、聚合):
AttributeTrigger- 创建一个Object视图
- 如果事件必须映射到对象实例,可选择创建SplitEvent
- 创建IdentityPartAttribute和任何所需的BasicEventAttribute实体
- 规则随后在中引用这些值属性
ScalarSelectStep
-
对于规则(每个事件触发、心跳、事件字段状态/变化):
EventTrigger- 使用最小图:Container → Source → SourceEvent → Rule(+ 可选)
fabricItemAction-v1 - 除非场景确实需要基于属性的建模,否则不要创建Object、SplitEvent、IdentityPartAttribute或BasicEventAttribute实体
- EventTrigger直接在/
FieldsDefaultsStep中读取原始事件字段EventDetectStep
- 使用最小图:Container → Source → SourceEvent → Rule(+ 可选
步骤5 — 规则(每个告警1个):
- 类型:,definition.type:
timeSeriesView-v1"Rule" - 始终添加,方便用户识别
"description": "Created by: skills-for-fabric" - Instance: 规则模板(参见rule-conditions.md)
- (v1.2.4):ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep
AttributeTrigger - (v1.2.4):FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep
EventTrigger
- 必须是JSON字符串(使用
instance)json.dumps() - 内的每个模板步骤都需要一个
instance.steps[]GUID。缺少步骤ID会导致表达式图无效,因为后端转换器使用步骤ID作为输出节点ID。id - 对于,设置
AttributeTrigger→ Object和parentObject→ ContainerparentContainer - 对于,设置
EventTrigger→ Container,除非设计明确要求,否则省略parentContainerparentObject - 默认使用,使新创建的规则处于启动/运行状态
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- 类型:— 当规则调用Fabric项(如Pipeline、Notebook、Spark作业定义、Dataflow或UDF / Function Set)时,使用此独立动作实体
fabricItemAction-v1 - 请参阅action-types.md获取架构
- 在规则的中,将
FabricItemBinding设置为独立fabricJobConnectionDocumentId;这是绑定行与动作实体之间的预期关联方式。fabricItemAction-v1.uniqueIdentifier - 对于UDF / 函数集动作,编写规则绑定并设置。在后续
itemType: "UserDataFunctions"回读中,独立getDefinition实体可能显示fabricItemAction-v1,而嵌入式payload.fabricItem.itemType: "FunctionSet"仍显示FabricItemBinding。UserDataFunctions - 对于UDF / 函数集动作,验证目标项是否实际公开非空函数列表,并将设置为发现的函数名称。参数名称和
subitemId值必须与发现的Fabric函数元数据完全匹配;省略目标函数未公开的参数。如果目标项没有注册函数,则Activator关联不完整,该动作不应视为有效。parameterType
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重要提示:definition.instance
是JSON字符串
definition.instanceinstancetimeSeriesView-v1definition❌ 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 to stringify. Do NOT use PowerShell's .
json.dumps()ConvertTo-JsontimeSeriesView-v1definitioninstance❌ 错误 — 原始模板对象(会失败):
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"
}使用进行字符串化。不要使用PowerShell的。
json.dumps()ConvertTo-JsonTwo Rule Template Types
两种规则模板类型
| Template | When to Use | Steps |
|---|---|---|
| Monitor attribute value (numeric, text, boolean) | ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep |
| 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.
| 模板 | 使用场景 | 步骤 |
|---|---|---|
| 监控属性值(数值、文本、布尔值) | ScalarSelectStep → ScalarDetectStep → (DimensionalFilterStep)* → ActStep |
| 事件发生时触发(状态、变化、心跳) | FieldsDefaultsStep → (EventDetectStep)+ → (DimensionalFilterStep)* → ActStep |
EventTrigger 没有ScalarSelectStep/ScalarDetectStep。直接对事件执行动作时使用。支持通过EventDetectStep进行状态、变化和心跳检测。
Must / Prefer / Avoid
必须做/推荐做/避免做
MUST DO
必须做
- Always use with
--resource https://api.fabric.microsoft.com— without it, token audience is wrongaz rest - Always send for
--body '{}'— it is a POST and omitting the body can cause 411 errorsgetDefinition - Always Base64-encode payload when calling
ReflexEntities.jsonupdateDefinition - Always JSON.stringify the field in
definition.instanceentities — 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 wrappertimeSeriesView-v1 - Always use the correct template type — for value-based conditions (has ScalarSelectStep + ScalarDetectStep),
AttributeTriggerfor event-based firing (has FieldsDefaultsStep + EventDetectStep, no ScalarDetectStep)EventTrigger - Always use new GUIDs for when adding entities — duplicate GUIDs cause corruption
uniqueIdentifier - Always update all cross-references when changing a — other entities reference it via
uniqueIdentifiertargetUniqueIdentifier - Handle LRO responses — ,
create, andgetDefinitionmay return 202; poll theupdateDefinitionheaderLocation
- 使用时始终传递
az rest— 缺少此参数会导致令牌受众错误--resource https://api.fabric.microsoft.com - 调用时始终发送
getDefinition— 这是POST请求,省略请求体可能导致411错误--body '{}' - 调用时始终对
updateDefinition负载进行Base64编码ReflexEntities.json - 始终对实体的
timeSeriesView-v1字段进行JSON.stringify — 它必须是字符串,而非嵌套对象。始终将规则模板包装在完整的实体信封中(参见上面的❌/✅示例) — 永远不要输出没有实体包装的原始模板对象definition.instance - 始终使用正确的模板类型 — 用于基于值的条件(包含ScalarSelectStep + ScalarDetectStep),
AttributeTrigger用于基于事件的触发(包含FieldsDefaultsStep + EventDetectStep,无ScalarDetectStep)EventTrigger - 添加实体时始终使用新的GUID作为— 重复的GUID会导致损坏
uniqueIdentifier - 修改时始终更新所有交叉引用 — 其他实体通过
uniqueIdentifier引用它targetUniqueIdentifier - 处理LRO响应 — 、
create和getDefinition可能返回202;轮询updateDefinition头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, 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 trueLogicalBecomes - Steady-state conditions such as ,
IsGreaterThan, orIsLessThanonly 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 semanticsIsOutsideRange
- 优先使用读取-修改-写入而非完全替换 — 获取当前定义,修改实体数组,然后更新
- 优先使用软删除而非硬删除,除非需要永久移除
- 通过工作区列表 + JMESPath动态发现ID,而非硬编码GUID
- 对于大多数告警,优先使用基于转换的告警条件而非稳态条件 — 即使用户使用类似"大于"、"低于"或"超出范围"的常规状态表述,也优先使用、
NumberBecomes、NumberEntersOrLeavesRange等检测器或显式变化条件。将普通告警表述视为"当它进入该状态时通知我",以避免条件持续成立时重复通知LogicalBecomes - 仅当用户明确要求在值保持触发状态时重复触发,例如"每次大于30时通知我"、"每次评估时只要高于30就触发",或者下游触发/窗口模式确实依赖该语义时,才使用、
IsGreaterThan或IsLessThan等稳态条件IsOutsideRange
AVOID
避免做
- Hardcoded workspace or item IDs — always resolve dynamically
- Forgetting the part — only include it with
.platformwhen usingupdateDefinition?updateMetadata=true - SELECT * without filtering on list endpoints — use pagination for large workspaces
- Modifying definitions of items with encrypted sensitivity labels — is blocked
getDefinition - 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 — PowerShell mangles quotes and special characters. Always write JSON to a temp file with
az rest --bodyand pass[System.IO.File]::WriteAllText($path, $json, [System.Text.UTF8Encoding]::new($false))--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的中使用内联JSON — PowerShell会破坏引号和特殊字符。始终使用
az rest --body将JSON写入临时文件,然后传递[System.IO.File]::WriteAllText($path, $json, [System.Text.UTF8Encoding]::new($false))--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.
Agent Integration Notes
Agent集成说明
- This skill uses the Fabric Items API () for CRUD and the Definition API for rule management
/reflexes - No additional data-plane protocols are needed — all operations use with the Fabric API audience
az rest - For reading Activator items and rules without modifying them, use the activator-consumption-cli skill instead
- 此技能使用Fabric项API ()进行CRUD操作,使用定义API进行规则管理
/reflexes - 无需额外的数据平面协议 — 所有操作使用带有Fabric API受众的
az rest - 如果仅需读取Activator项和规则而不修改,请改用activator-consumption-cli技能