EventGrid 触发器 - 如何从 triggerbody 设置 clienttrackingid?
EventGrid Trigger - How to set clienttrackingid from triggerbody?
在请求跨越多个服务(包括 eventgrid)的微服务环境中,我想使用 correlationid 配置端到端日志记录。
受此博客启发 https://toonvanhoutte.wordpress.com/2018/08/05/end-to-end-correlation-across-logic-apps/
我如何配置 EventGrid 触发器 clientTrackingId 与事件数据负载中的相关性?
检查下面我的定义,它不起作用。
如果我用字符串值或什至“@parameters('$connections')['azureeventgrid']['connectionId']" 它就像一个魅力。
"triggers": {
"When_a_resource_event_occurs": {
"correlation": {
"clientTrackingId": "@{coalesce(json(triggerBody().Data)?.CorrelationNr, guid())}"
},
"inputs": {
"body": {
"properties": {
"destination": {
"endpointType": "webhook",
"properties": {
"endpointUrl": "@{listCallbackUrl()}"
}
},
"filter": {
"includedEventTypes": [
"webhook.sp.updated"
]
},
"topic": "/subscriptions/xxxx/resourceGroups/xxx/providers/Microsoft.EventGrid/topics/WebHookManager"
}
},
"host": {
"connection": {
"name": "@parameters('$connections')['azureeventgrid']['connectionId']"
}
},
"path": "/subscriptions/@{encodeURIComponent('xxx')}/providers/@{encodeURIComponent('Microsoft.EventGrid.Topics')}/resource/eventSubscriptions",
"queries": {
"x-ms-api-version": "2017-06-15-preview"
}
},
"splitOn": "@triggerBody()",
"type": "ApiConnectionWebhook"
}
}
逻辑应用没有触发。没有错误消息。
请检查关于 clientTrackingId 的描述,您的逻辑应用没有 运行 的历史是因为您的 triggerBody()
没有 CorrelationNr
与您显示的定义.
实际上您的事件网格触发器已检测到该事件,只是无法 运行 符合逻辑。您可以转到 EVALUATION
并检查触发历史记录。是因为值为null,所以不会运行.
如果你使用HTTP请求触发器,你可以设置x-my-custom-correlation-id
header。或在 json body 中设置任何 key-value,然后像 @{coalesce(json(triggerBody())['keyname'], guid())}
.
一样设置 clientTrackingId
并且如果您在不使用 header 的情况下使用某些触发器,则必须使用字符串或其他参数指向该值,就像您所说的 connectionid 或您自定义的参数值,如下所示。
所以重点是 clientTrackingId
必须在它之前设置 运行 并且可以获取值。
在请求跨越多个服务(包括 eventgrid)的微服务环境中,我想使用 correlationid 配置端到端日志记录。 受此博客启发 https://toonvanhoutte.wordpress.com/2018/08/05/end-to-end-correlation-across-logic-apps/
我如何配置 EventGrid 触发器 clientTrackingId 与事件数据负载中的相关性?
检查下面我的定义,它不起作用。 如果我用字符串值或什至“@parameters('$connections')['azureeventgrid']['connectionId']" 它就像一个魅力。
"triggers": {
"When_a_resource_event_occurs": {
"correlation": {
"clientTrackingId": "@{coalesce(json(triggerBody().Data)?.CorrelationNr, guid())}"
},
"inputs": {
"body": {
"properties": {
"destination": {
"endpointType": "webhook",
"properties": {
"endpointUrl": "@{listCallbackUrl()}"
}
},
"filter": {
"includedEventTypes": [
"webhook.sp.updated"
]
},
"topic": "/subscriptions/xxxx/resourceGroups/xxx/providers/Microsoft.EventGrid/topics/WebHookManager"
}
},
"host": {
"connection": {
"name": "@parameters('$connections')['azureeventgrid']['connectionId']"
}
},
"path": "/subscriptions/@{encodeURIComponent('xxx')}/providers/@{encodeURIComponent('Microsoft.EventGrid.Topics')}/resource/eventSubscriptions",
"queries": {
"x-ms-api-version": "2017-06-15-preview"
}
},
"splitOn": "@triggerBody()",
"type": "ApiConnectionWebhook"
}
}
逻辑应用没有触发。没有错误消息。
请检查关于 clientTrackingId 的描述,您的逻辑应用没有 运行 的历史是因为您的 triggerBody()
没有 CorrelationNr
与您显示的定义.
实际上您的事件网格触发器已检测到该事件,只是无法 运行 符合逻辑。您可以转到 EVALUATION
并检查触发历史记录。是因为值为null,所以不会运行.
如果你使用HTTP请求触发器,你可以设置x-my-custom-correlation-id
header。或在 json body 中设置任何 key-value,然后像 @{coalesce(json(triggerBody())['keyname'], guid())}
.
clientTrackingId
并且如果您在不使用 header 的情况下使用某些触发器,则必须使用字符串或其他参数指向该值,就像您所说的 connectionid 或您自定义的参数值,如下所示。
所以重点是 clientTrackingId
必须在它之前设置 运行 并且可以获取值。