'Use AzureFunction to connect to LogicApp

I have a LogicApp which can connect to an Azure database and SFTP etc, so all API connections have been created which can be viewed in API Connections in Azure. But for simplicity for now I just want to be able to connect to the API shown below simply by calling this JSON Body:

{
    "SFTPConnection":"WhiteStuffSFTP"
}

enter image description here

The code to my very basic LogicApp is below, which simply connects to the WhiteStuffSFTP API shown above.

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Get_file_content": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['WhiteStuffSFTP']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent('L2hvbWUvVGVzdC5jc3Y='))}/content",
                    "queries": {
                        "inferContentType": true
                    }
                },
                "metadata": {
                    "L2hvbWUvVGVzdC5jc3Y=": "/home/Test.csv"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {
                        "properties": {
                            "SFTPConnection": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "WhiteStuffSFTP": {
                    "connectionId": "/subscriptions/fc4e844a-4aad-4e33-8f54-41494548f8b5/resourceGroups/ws-dataplatform/providers/Microsoft.Web/connections/WhiteStuffSFTP",
                    "connectionName": "WhiteStuffSFTP",
                    "id": "/subscriptions/fc4e844a-4aad-4e33-8f54-41494548f8b5/providers/Microsoft.Web/locations/uksouth/managedApis/sftpwithssh"
                }
            }
        }
    }
}

which works perfectly fine when the API connection has been hardcoded in the LogicApp: enter image description here

So I tried going into the code within LogicApp and changed

"connection": {
                            "name": "@parameters('$connections')['WhiteStuffSFTP']['connectionId']"
                        }

to

"connection": {
                            "name": "@{encodeURIComponent(encodeURIComponent(triggerBody()?['SFTPConnection']))}"
                        }

But I'm getting this error: enter image description here



Solution 1:[1]

Yes, it is possible in Logic app. You can follow the Link to achieve this. Or you can use the Durable Function to achieve your needs.

Refer here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DelliganeshS-MT