1

我用 logicAPP 创建了一个工作流。目标是在 VM 缺少补丁时通知团队。我在逻辑应用程序中使用 azure monitor 来设置查询。我决定在 Azure Monitor 之后放置一个条件,以了解查询表是否为空或有数据。如果表为空,则 logix 为 true ,因此它不发送通知,当它为 false 时,它​​发送通知。

运行时,出现逻辑错误。通常,表没有数据,但在条件之后,函数 empty([my_table]) 返回 false 并向我发送结果通知(“查询未产生数据”)

问题是什么 ??

谢谢

在此处输入图像描述

4

1 回答 1

1

基于上述共享要求,我们创建了逻辑应用程序并在我们的本地环境中对其进行了测试,它工作正常。

以下是完整的逻辑代码:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Condition_2": {
                "actions": {
                    "Terminate_2": {
                        "inputs": {
                            "runStatus": "Cancelled"
                        },
                        "runAfter": {},
                        "type": "Terminate"
                    }
                },
                "else": {
                    "actions": {
                        "Send_an_email_(V2)_2": {
                            "inputs": {
                                "body": {
                                    "Body": "<p>@{base64ToString(body('Run_query_and_visualize_results')?['body'])}</p>",
                                    "Subject": "list of vm from update management ",
                                    "To": "<UserEmailId>"
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['office365']['connectionId']"
                                    }
                                },
                                "method": "post",
                                "path": "/v2/Mail"
                            },
                            "runAfter": {},
                            "type": "ApiConnection"
                        }
                    }
                },
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@length(body('Run_query_and_visualize_results')?['body'])",
                                0
                            ]
                        }
                    ]
                },
                "runAfter": {
                    "Run_query_and_visualize_results": [
                        "Succeeded"
                    ]
                },
                "type": "If"
            },
            "Run_query_and_visualize_results": {
                "inputs": {
                    "body": "Update\n| where Classification == 'Security Updates' or Classification  == 'Critical Updates'\n| where UpdateState == 'Needed'\n| summarize by Computer,ResourceGroup,Classification,UpdateState\n|sort by Computer",
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azuremonitorlogs']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/visualizeQuery",
                    "queries": {
                        "resourcegroups": "<Resource_group_Name",
                        "resourcename": "<log analytics workspacename",
                        "resourcetype": "Log Analytics Workspace",
                        "subscriptions": "<subcription_id>",
                        "timerange": "Last 12 hours",
                        "visType": "Html Table"
                    }
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "evaluatedRecurrence": {
                    "frequency": "Hour",
                    "interval": 3
                },
                "recurrence": {
                    "frequency": "Hour",
                    "interval": 3
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "azuremonitorlogs": {
                    "connectionId": "/subscriptions/<subcription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/connections/azuremonitorlogs",
                    "connectionName": "azuremonitorlogs",
                    "id": "/subscriptions/<subcription-id>/providers/Microsoft.Web/locations/northcentralus/managedApis/azuremonitorlogs"
                },
                "office365": {
                    "connectionId": "/subscriptions/<subcription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/connections/office365",
                    "connectionName": "office365",
                    "id": "/subscriptions/<subcription-id>/providers/Microsoft.Web/locations/northcentralus/managedApis/office365"
                }
            }
        }
    }
}

请找到上述逻辑示例运行的参考输出:

在此处输入图像描述

于 2021-09-06T09:03:59.610 回答