繁体   English   中英

在逻辑应用程序中获取 Azure Function 的 output 时出现问题

[英]Problem getting the output of an Azure Function in a Logic App

尝试在我的 Logic 应用程序中获取 Azure Function 的 output 时遇到了一些问题。

当我查看 azure function output 时,在正文中, "m_StringValue"返回了我想要的。 当我在此之后设置一个条件以检查 azure function 主体是否返回了我想要的内容时,它返回 false。

Azure 逻辑应用流程:

Azure 逻辑应用流

Azure 逻辑应用程序 output:

Azure 逻辑应用输出

应用代码如下

{
    "$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"
            }
        }
    }
}

您的条件正文包含“abc”是错误的。 它认为它将 Body 读取为 object。

尝试添加“Parse Json”语句,然后将条件更改为仅检查字符串值字段。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM