azureblockchainazure-logic-appsazure-blockchain-service

How to dynamically pass an argument to a function being called by a logic app with ethereum connector in Azure?


I am using Azure blockchain Service and I made a logic app to call a function inside a smart contract whenever a particular trigger occurs. While creating the logic app it asks me the argument with which I want to call the function. Now, I do not want to hard code the argument.

It is something like on my website, there are multiple products available, and whichever product the user chooses, the function should be called with the name of the product as the argument.


Solution

  • You have two options here

    1. HTTP triggered function and pass parameters using POST request
    2. Queue triggered function and pass parameters using Azure Storage Queue

    In first case you simply create HTTP trigger

    enter image description here

    Body configured as

    {
        "type": "object",
        "properties": {
            "product": {
                "type": "string"
            }
        }
    }
    

    This means logic app request expects JSON like this

    {
        "product" : "abc"
    }
    

    This way you can use product from trigger

    enter image description here

    And use it as parameter for function call using either HTTP action

    enter image description here

    or Azure Function action

    enter image description here

    If you want to learn more about logic apps feel free to check my video intro on it https://youtu.be/ZvsOzji_8ow

    If you are worried about publicly accessible webhooks for logic apps use Azure Storage Queue with Azure AD authentication or cover logic app with API management like described here https://marczak.io/posts/2019/08/secure-logic-app-with-api-management/