逻辑应用发布到 Microsoft Teams 数据未显示在字段中

Posted

技术标签:

【中文标题】逻辑应用发布到 Microsoft Teams 数据未显示在字段中【英文标题】:Logic App posting to Microsoft Teams data not showing in fields 【发布时间】:2020-09-23 04:13:33 【问题描述】:

我在我的应用服务中创建了一个向逻辑应用发送警报的警报,然后逻辑应用向 Microsoft Teams 发布消息。 https://docs.microsoft.com/en-us/azure/azure-monitor/platform/action-groups-logic-app

一切都按预期工作,接受我可以从个人获取数据到我的消息中。

我在逻辑应用程序的架构中使用了以下内容


    "schemaId": "azureMonitorCommonAlertSchema",
    "data": 
        "essentials": 
            "alertId": "/subscriptions/MyAlert",
            "alertRule": "Web - Test teams",
            "severity": "Sev1",
            "signalType": "Metric",
            "monitorCondition": "Fired",
            "monitoringService": "Platform",
            "alertTargetIDs": [
                "/subscriptions/MySub"
            ],
            "originAlertId": "bd40051b-35fa-,
            "firedDateTime": "2020-06-03T14:53:34.0942607Z",
            "description": "",
            "essentialsVersion": "1.0",
            "alertContextVersion": "1.0"
        ,
        "alertContext": 
            "properties": null,
            "conditionType": "SingleResourceMultipleMetricCriteria",
            "condition": 
                "windowSize": "PT5M",
                "allOf": [
                    
                        "metricName": "Http2xx",
                        "metricNamespace": "Microsoft.Web/sites",
                        "operator": "GreaterThan",
                        "threshold": "5",
                        "timeAggregation": "Total",
                        "dimensions": [
                            
                                "name": "ResourceId",
                                "value": "MyWebs.com"
                            
                        ],
                        "metricValue": 24,
                        "webTestName": null
                    
                ],
                "windowStartTime": "2020-06-03T14:45:23.095Z",
                "windowEndTime": "2020-06-03T14:50:23.095Z"
            
        
    

然后在设计器中添加字段

这是消息正文的逻辑代码视图中的详细信息 “内容”:“

您的 Azure Monitor 警报已触发\nAzure Monitor 警报规则 Web - 测试团队在 @triggerBody()?['body']?['data']?['alertContext']?[' 触发条件']?['windowEndTime']\n\n规则:@triggerBody()?['body']?['data']?['essentials']?['alertRule'] \n正文:@triggerBody()\n标题:@triggerOutputs()['headers']\nheaders:@triggerBody()?['headers']\essentials:@triggerBody()?['body']?['data']?['essentials']\ndata:@triggerBody()?['body']?['data' ]\nbody:@triggerBody()?['body']

"

唯一填充的字段是正文,没有任何特定字段

您的 Azure Monitor 警报已触发 Azure 监视器警报规则 Web - 测试团队在

触发

规则: 正文:"schemaId":"azureMonitorCommonAlertSchema","data":"essentials":"alertId":"/subscriptions/bresourceGroups/Microsoft.AlertsManagement/alerts","alertRule":"Web - 测试警报","严重性":"Sev0","signalType":"Metric","monitorCondition":"Fired","monitoringService":"Platform","alertTargetIDs":[""],"originAlertId":"":"2020- 06-03T15:49:20.1712118Z","description":"","essentialsVersion":"1.0","alertContextVersion":"1.0","alertContext":"properties":null,"conditionType":" SingleResourceMultipleMetricCriteria","condition":"windowSize":"PT5M","allOf":["metricName":"Http2xx","metricNamespace":"Microsoft.Web/sites","operator":"GreaterThan", "threshold":"3","timeAggregation":"Count","dimensions":["name":"ResourceId","value":""],"metricValue":7.0,"webTestName":null ],"windowStartTime":"2020-06-03T15:41:05.994Z","windowEndTime":"2020-06-03T15:46:05.994Z" 标头:"Connection":"Keep-Alive","Expect":"100-continue","Host":"prod-06.uksouth.logic.azure.com","User-Agent":"IcMBroadcaster/ 1.0","X-CorrelationContext":"RkkKACgAAAACAAAAEABEgMLahbH0Sqw1EVoRy7Y8AQAQANlpmHhZlSRMkU6bLTb+DSk=","Content-Length":"1254","Content-Type":"application/json; charset=utf-8" 标题: 要领: 数据: 正文:

【问题讨论】:

您还可以使用“Parse JSON”操作来解析触发器中的Body,并在“发布消息”操作中使用“解析 JSON”中的字段。 【参考方案1】:

我不得不手动更新逻辑代码并删除额外的正文标签

原创

@triggerBody()?['body']?['data']?['alertContext']?['condition']?['windowEndTime']

到这里

@triggerBody()?['data']?['alertContext']?['condition']?['windowEndTime']

【讨论】:

以上是关于逻辑应用发布到 Microsoft Teams 数据未显示在字段中的主要内容,如果未能解决你的问题,请参考以下文章

使用 Team 的附件按钮将文件上传到 bot 应用程序时,Microsoft Teams 返回错误

microsoft-teams:我们如何更新所有用户的应用程序?缺乏功能加上问题

如何在 Microsoft Teams 应用中代表用户发布消息?

Duang!Microsoft Teams助你云办公

IndexedDB 不适用于 Microsoft Teams 的 Android 应用程序

将 Azure 托管的机器人添加到 Microsoft Teams 开发门户