1
votes

I have an Azure API Management API when called should execute some logic and based on it will execute either 2 new API's or 3 new API's based on the logic and return the result from the logic apps. I am assuming logic apps should be able to do that. I need a way to do it or atleast need some suggestion how can i possibly proceed

I am not sure how to trigger a Logic app when an API gets called, It should connect to Logic App

1

1 Answers

2
votes

To integrate Logic Apps with Azure API Management (APIM), create an HTTP endpoint in Logic Apps. Next, generate a SAS token for the Logic App. This will be used to secure the endpoint. Read the documentation on further restricting by IP.

To trigger the Logic App, set the backend URL of your API definition in APIM, or if composing multiple backend calls, use a custom XML policy that would look something like the below:

<send-request mode="new" response-variable-name="[resultVariableName]" timeout="20" ignore-error="true">
  <set-url>https://prod-23.centralus.logic.azure.com:443/workflows/0c9def69700c4b2995e2e587123306f7/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=ORQeXlFZxBeF7xmF9pO73sgYl_-w0v6V9uugi8bhHeA</set-url>
  <set-method>POST</set-method>
  <set-header name="Content-Type" exists-action="override">
    <value>application/json</value>
  </set-header>
  <set-body>@($"token={(string)context.Variables["someVariable"]}")</set-body>
</send-request>

While I'm providing the answer, I would NOT recommend this solution, practically. This is an anti-pattern for reliability. If at any point in the HTTP call chain, a timeout occurs or fails, it will create a situation that will be difficult to verify the correctness of the program.