I have and existing Logic App Standard with a few workflows. The goal is to create additional workflows using REST API.
CodePudding user response:
To create a new workflow in your standard logic app. You can change the kind to Stateless or Stateful as per your requirement and update the trigger/action/output in the request body as per your requirement.
POST https://management.azure.com/subscriptions/{subscription ID}/resourceGroups/{resource group name}/providers/Microsoft.Web/sites/{logic app name}/deployWorkflowArtifacts?api-version=2018-11-01 Authorization: Bearer
Request Body: {"files":{"<>/workflow.json":{"definition":{"$schema":https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#,"actions":{},"contentVersion":"1.0.0.0","outputs":{},"triggers":{"manual":{"inputs":{},"kind":"Http","type":"Request"}}},"kind":"Stateful"}}}
To Update the existing workflow in standard logic app
POST https://management.azure.com/subscriptions/{subscription ID}/resourceGroups/{resource group name}/providers/Microsoft.Web/sites/{logic app name}/hostruntime/runtime/webhooks/workflow/api/management/workflows/{yourworkflowname}/validate?api-version=2018-11-01 Authorization: Bearer
Request Body: {"properties":{"definition":{"$schema":https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#,"actions":{},"contentVersion":"1.0.0.0","outputs":{},"triggers":{"manual":{"inputs":{},"kind":"Http","type":"Request"}}},"kind":"Stateful"}}
The standard logic app is built on top of the azure function app runtime, and it uses the same REST API as azure function. Make sure to add Content-Type as application/json in the header To get familiar with function REST API you can refer to this document. To get familiar with Azure Management API and generating token refer to this document.