Ben
Ben

Reputation: 979

Create azure logic app from azure function

I am wondering if there is a way to create an Azure logic app (given we have the definition of the logic app as a JSON file) from an Azure function.

To be more clear, I have done this in the past with AWS Lambda and State Machine (here). As you can see given the definition of statemachine we can call CreateStateMachine in a Lambda function with additional required fields and create a state machine.

Knowing the concept of Azure Logic App is almost similar to AWS Statemachine and Azure function to AWS Lambda, I was wondering if there is a way to achieve this. If you know it please guide me to the documentation.

Upvotes: 0

Views: 144

Answers (1)

HariHaran
HariHaran

Reputation: 4199

Yes you can create or perform any other Workflow Operations on Azure Logic Apps using the REST APIs.

You need to send a PUT request to the below URL with your logicapp definition.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}?api-version=2016-06-01

Remember you will also need a bearer_token to Authenticate your request.

Create Or Update Logic App(Workflow) -> Documentation

Possible workflow operations - Docs

To get Bearer Token use the below snippet

string authority = $"https://login.windows.net/{request.TenantId}";

var authContext = new AuthenticationContext(authority);
var credential = new ClientCredential(request.ClientId, request.ClientSecret);
var authResult = authContext.AcquireTokenAsync(Resource, credential).Result;
var accessToken = authResult.AccessToken; 

Upvotes: 1

Related Questions