Simple Logic app, that gets 20 orders

In this post we create a simple Azure Logic App, that will authorize to VC3 Platform and get 20 orders.

Prerequisites

Step 1. Create a new Project in Visual Studio

In “Create a new project” dialog choose “Azure Resource Group” template:

After you fill-in name for the application, it will ask for the certain project template. Choose “Logic App”:
image
Please rename all files: LogicApp.json to LogicApp-YourLogicAppProjectName.json, LogicApp.parameters.json to LogicApp-YourLogicAppProjectName.parameters.json. In our sample, the name will be LogicApp-IntegrationOrder. Don’t forget about references to these files inside Deploy- IntegrationOrder.ps1 file.

All the logic will be implemented in LogicApp-IntegrationOrder.json. Input parameters for our application will be automatically added into LogicApp-IntegrationOrder.parameters.json on deploy through the Visual Studio.

You have 3 ways to edit LogicApp-IntegrationOrder.json file:

  • Logic App Designer design mode
  • Logic App Designer code view mode
  • Simple text-editor mode

After the app is created, we can code the logic – open LogicApp-IntegrationOrder.json for edit and implement the algorithm:

  • Create needed input parameters for settings authorization data and platform url
  • Create trigger for launching our app
  • Connect to platform, authorize (get OAuth token)
  • Run HTTP query authorizing with OAuth token

Step 2. Create needed input parameters for settings authorization data and platform url

In parameters section we add lines, that describe input parameters for our app. That variable values will be asked for later when we will deploy our application to Azure:

In resources.definition.parameters section we add same lines – parameters for your workflow definition (parameters, that your logic app uses at runtime):

In resources.properties.parameters we pass input parameter values from app to workflow definition:

Step 3. Create trigger for launching our app

Open Logic App Designer ( right-click on LogicApp-IntegrationOrder.json -> Open Logic App Designer ) and add the very first endpoint – Recurrence (Schedule):
image
image

Step 4. Connect to platform, authorize (get token) and parse it to variable

In actions section we add: GetToken and ParseToken endpoints to be authorized:

Step 5. Run http query using OAuth

Now, we have OAuth token and need to call appropriate API for getting orders. Go to swagger api page and choose your section:
image

Here you can get query uri and apiDefinitionUrl:
image

In actions section we add:

By the way, you can edit all endpoint properties through the Logic App Designer. For example, header:

Step 6. Add Delay endpoint

image
image
Now, you can see full logic app workflow in the designer: Logic App Designer
image
Our application is ready to deploy!

Step 7. Deploy Logic App to Azure

Right-click on project -> Deploy -> New Deploy
image
Click deploy, and see the window Edit Parameters open. Fill-in needed parameters, click Save:
image
After that, you can go to Azure portal and see the Logic App run history:
image

You can click on the entry in Runs history list and see the full flow you created:

After you edit Logic App, that is already deployed you can re-deploy it in the same way - Right-click on the project -> Deploy -> select your deployment options (or create new ones if needed).

1 Like