Проблема с выводом функции Azure в приложение логики - PullRequest
0 голосов
/ 14 октября 2019

У меня возникают некоторые проблемы при попытке получить выходные данные функции Azure в моем приложении логики.

Когда я смотрю на вывод функции azure в теле, "m_StringValue" возвращает то, что я хочу. Когда я ставлю условие сразу после этого, чтобы проверить, вернул ли тело функции Azure желаемое, оно возвращает false.

Поток приложения логики Azure:

Azure Logic App flow

Вывод приложения Azure Logic:

Azure Logic App output

Код приложения следующий

{
    "$connections": {
        "value": {
            "azureblob_1": {
                "connectionId": "x",
                "connectionName": "azureblob-5",
                "id": "x"
            },
            "office365": {
                "connectionId": "x",
                "connectionName": "office365-5",
                "id": "x"
            }
        }
    },
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Is_from_a_known_sender": {
                "actions": {
                    "Should_be_forwarded_to_a": {
                        "actions": {},
                        "else": {
                            "actions": {
                                "Should_be_forwarded_to_b": {
                                    "actions": {
                                        "For_each": {
                                            "actions": {
                                                "Condition_2": {
                                                    "actions": {},
                                                    "expression": {
                                                        "and": [
                                                            {
                                                                "contains": [
                                                                    "@body('Parse_JSON')?['properties']?['m_StringValue']",
                                                                    "abc"
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    "runAfter": {
                                                        "Parse_JSON": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "If"
                                                },
                                                "Create_blob_for_each_attachment": {
                                                    "inputs": {
                                                        "body": "@base64ToBinary(items('For_each')?['ContentBytes'])",
                                                        "host": {
                                                            "connection": {
                                                                "name": "@parameters('$connections')['azureblob_1']['connectionId']"
                                                            }
                                                        },
                                                        "method": "post",
                                                        "path": "/datasets/default/files",
                                                        "queries": {
                                                            "folderPath": "/attachments",
                                                            "name": "@items('For_each')?['Name']",
                                                            "queryParametersSingleEncoded": true
                                                        }
                                                    },
                                                    "runAfter": {},
                                                    "runtimeConfiguration": {
                                                        "contentTransfer": {
                                                            "transferMode": "Chunked"
                                                        }
                                                    },
                                                    "type": "ApiConnection"
                                                },
                                                "ExtractTextFromPDF": {
                                                    "inputs": {
                                                        "body": "@body('Get_blob_content')",
                                                        "function": {
                                                            "id": "x"
                                                        }
                                                    },
                                                    "runAfter": {
                                                        "Get_blob_content": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Function"
                                                },
                                                "Get_blob_content": {
                                                    "inputs": {
                                                        "host": {
                                                            "connection": {
                                                                "name": "@parameters('$connections')['azureblob_1']['connectionId']"
                                                            }
                                                        },
                                                        "method": "get",
                                                        "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(body('Create_blob_for_each_attachment')?['Id']))}/content",
                                                        "queries": {
                                                            "inferContentType": true
                                                        }
                                                    },
                                                    "runAfter": {
                                                        "Create_blob_for_each_attachment": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "ApiConnection"
                                                },
                                                "Parse_JSON": {
                                                    "inputs": {
                                                        "content": "@body('ExtractTextFromPDF')",
                                                        "schema": {
                                                            "properties": {
                                                                "m_MaxCapacity": {
                                                                    "type": "integer"
                                                                },
                                                                "m_StringValue": {
                                                                    "type": "string"
                                                                }
                                                            },
                                                            "type": "object"
                                                        }
                                                    },
                                                    "runAfter": {
                                                        "ExtractTextFromPDF": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "ParseJson"
                                                }
                                            },
                                            "foreach": "@triggerBody()?['Attachments']",
                                            "runAfter": {},
                                            "type": "Foreach"
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "contains": [
                                                    "@triggerBody()?['From']",
                                                    "xandreu"
                                                ]
                                            }
                                        ]
                                    },
                                    "runAfter": {},
                                    "type": "If"
                                }
                            }
                        },
                        "expression": {
                            "and": [
                                {
                                    "contains": [
                                        "@triggerBody()?['From']",
                                        "test"
                                    ]
                                }
                            ]
                        },
                        "runAfter": {},
                        "type": "If"
                    }
                },
                "expression": {
                    "and": [
                        {
                            "or": [
                                {
                                    "contains": [
                                        "@triggerBody()?['From']",
                                        "xandreu"
                                    ]
                                }
                            ]
                        },
                        {
                            "equals": [
                                "@triggerBody()?['HasAttachment']",
                                true
                            ]
                        }
                    ]
                },
                "runAfter": {},
                "type": "If"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "When_a_new_email_arrives": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['office365']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/Mail/OnNewEmail",
                    "queries": {
                        "fetchOnlyWithAttachment": true,
                        "folderPath": "Inbox",
                        "importance": "Any",
                        "includeAttachments": true
                    }
                },
                "recurrence": {
                    "frequency": "Minute",
                    "interval": 3
                },
                "splitOn": "@triggerBody()?['value']",
                "type": "ApiConnection"
            }
        }
    }
}

1 Ответ

2 голосов
/ 14 октября 2019

Ваше состояние Тело содержит "abc" неправильно. Он думает, что читает Body как объект.

Попробуйте добавить инструкцию "Parse Json", а затем измените ваше условие, чтобы проверять только поле строкового значения.

enter image description here

...