进行操作直到Azure逻辑应用程序中的条件无法按预期运行

时间:2019-03-10 17:07:34

标签: azure loops azure-logic-apps

我有一个使用“直到”动作的逻辑应用程序。条件检查API调用的状态:

enter image description here

"Wait_Until_Cube_Processing_is_finished_": {
                "actions": {
                    "Get_Status_of_Model": {
                        "inputs": {
                            "authentication": {
                                "audience": "https://*.asazure.windows.net",
                                "clientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
                                "secret": "OxxxxxxxxxxxxzskHxxxxxxxxxxxxxutjODXxxxxxx=",
                                "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                                "type": "ActiveDirectoryOAuth"
                            },
                            "method": "GET",
                            "uri": "https://northeurope.asazure.windows.net/servers/ServerName/models/modelName/refreshes/@{body('Filter_array')[0].refreshId}"
                        },
                        "runAfter": {},
                        "type": "Http"
                    }
                },
                "expression": "@equals('status', 'succeeded')",
                "limit": {
                    "timeout": "PT1H"
                },
                "runAfter": {
                    "Filter_array": [
                        "Succeeded"
                    ]
                },
                "type": "Until"
            }
        },

API返回这样的状态:

{
  "startTime": "2019-03-10T15:50:55.1278586Z",
  "type": "full",
  "status": "notStarted",
  "currentRefreshType": "full",
  "objects": [
    {
      "table": "Table1",
      "partition": "Partition_03",
      "status": "notStarted"
    }
  ]
}

我的状况不正常。它运行一小时,一小时后进入下一步。但是20分钟后我的http请求收到以下状态:

 {
    "refreshId": "dbxxxxxx-exxx-xxxx-xxx-3xxxxxxdaxxx",
    "startTime": "2019-03-10T15:50:55.48",
    "endTime": "2019-03-10T16:14:56.267",
    "status": "succeeded"
  }

您有什么主意,为什么我的直到操作不起作用?

1 个答案:

答案 0 :(得分:1)

这是您的条件表达问题。您的表情是"expression": "@equals('status', 'succeeded')"。这意味着您将字符串status与字符串succeeded进行比较,它们将永远相等。这就是为什么您的循环总是遇到超时PT1H的原因。超时默认值为PT1H,即一小时。

因此,您应该获取请求正文,然后将正文中的状态与成功进行比较。流程如下:

enter image description here

响应主体是数组格式,因此,如果要在示例中获取状态,则表达式为@body('HTTP_2')['properties']['state'],下面是我的响应主体,则可以引用此表达式。

enter image description here