具有天蓝色监视器和条件的逻辑应用程序

Posted

技术标签:

【中文标题】具有天蓝色监视器和条件的逻辑应用程序【英文标题】:Logic App with azure monitor and conditions 【发布时间】:2021-11-01 02:18:26 【问题描述】:

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

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

有什么问题??

谢谢

【问题讨论】:

【参考方案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"
                
            
        
    

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

【讨论】:

以上是关于具有天蓝色监视器和条件的逻辑应用程序的主要内容,如果未能解决你的问题,请参考以下文章

它是一种以语法方式取消已经运行的天蓝色逻辑应用程序还是使用 HTTP 调用的方法

有没有办法在标准逻辑应用程序中获取特定工作流的天蓝色门户 URL?

Terraform:删除身份块不会删除从资源天蓝色逻辑应用程序分配的身份

java并发条件阻塞Condition的应用

Azure 逻辑应用返回多个响应

程序员的数学