# Simple Logic app, that gets 20 orders

**URL:** <https://www.virtocommerce.org/t/simple-logic-app-that-gets-20-orders/230>\
**Category:** howto\
**Tags:** azure, module, integration\
**Created:** [May 29, 2020, 1:47pm UTC](https://www.virtocommerce.org/t/simple-logic-app-that-gets-20-orders/230 "2020-05-29T13:47:27Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![OlegoO](https://yyz2.discourse-cdn.com/flex032/user_avatar/www.virtocommerce.org/olegoo/32/27_2.png) [@OlegoO](https://www.virtocommerce.org/u/OlegoO)\
**Post date:** [May 29, 2020, 1:47pm UTC](https://www.virtocommerce.org/t/simple-logic-app-that-gets-20-orders/230/1 "2020-05-29T13:47:27Z")

</div>

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

## Prerequisites

- An Azure subscription. If you don’t have an Azure subscription, [sign up for a free Azure account](https://azure.microsoft.com/free/).
- Azure Logic Apps Tools for Visual Studio: [https://marketplace.visualstudio.com/items?itemName=VinaySinghMSFT.AzureLogicAppsToolsForVS2019](https://marketplace.visualstudio.com/items?itemName=VinaySinghMSFT.AzureLogicAppsToolsForVS2019)
- The URL for the Swagger file that describes the target REST endpoint for VC Platform. The platform must be hosted on an HTTPS URL and be publicly accessible.

## Step 1. Create a new Project in Visual Studio

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

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/b081798219c83843e3219308c64134f35e62b6a4.png)

After you fill-in name for the application, it will ask for the certain project template. Choose “Logic App”:  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/eaf4e0890b366a001da509be27603072708391d7.png)  
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:

> <https://github.com/VirtoCommerce/vc-samples/blob/0840a706cbc973df7f79891b376607232c3ac0f2/IntegrationOrders/IntegrationOrders/LogicApp-IntegrationOrders.json#L54-L62>

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

> <https://github.com/VirtoCommerce/vc-samples/blob/0840a706cbc973df7f79891b376607232c3ac0f2/IntegrationOrders/IntegrationOrders/LogicApp-IntegrationOrders.json#L375-L383>

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

> <https://github.com/VirtoCommerce/vc-samples/blob/0840a706cbc973df7f79891b376607232c3ac0f2/IntegrationOrders/IntegrationOrders/LogicApp-IntegrationOrders.json#L343-L351>

## 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](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/a91a02eadda009bd41f3e69a297e58b583379710.png)  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/26f5d558c6a0b34cb7594c57160d3b3965d13bce.png)

## 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:

> <https://github.com/VirtoCommerce/vc-samples/blob/0840a706cbc973df7f79891b376607232c3ac0f2/IntegrationOrders/IntegrationOrders/LogicApp-IntegrationOrders.json#L151-L185>

## 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](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/dbe1d76d3119cd113b63975a04d86e368df5b56c.png)

Here you can get query uri and apiDefinitionUrl:  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/96d52f15790bcac888e5cd5b051f09258ccf04d7.png)

In **actions** section we add:

> <https://github.com/VirtoCommerce/vc-samples/blob/0840a706cbc973df7f79891b376607232c3ac0f2/IntegrationOrders/IntegrationOrders/LogicApp-IntegrationOrders.json#L192-L216>

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

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/a4939acb870e322f764edc1900a89d2a75d6e9b3.png)

## Step 6. Add Delay endpoint

![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/753be634cd198c4fb6a9f59631245db400231c70.png)  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/a084a88dc9fd12aef0ac0c1ed909eb4ea43e3433.png)  
Now, you can see full logic app workflow in the designer: **Logic App Designer**  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/2cb9eefe26cbc336074972967e9a8bd1c5cb5b2e.png)  
Our application is ready to deploy!

## Step 7. Deploy Logic App to Azure

Right-click on project -\> **Deploy -\> New Deploy**  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/6acca28c109e167381429de085db3166665af536.png)  
Click deploy, and see the window Edit Parameters open. Fill-in needed parameters, click Save:  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/6b3953e4964139b17d2882d453df4f980ab96265.png)  
After that, you can go to Azure portal and see the Logic App run history:  
 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/ddc1f9b27daeb703586fb5b5cad7cde2843cc136.png)

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

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/virtocommerce/original/1X/c3cbfe6c31be32518896a683500c8d8a4170f2a0.png)

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).

---

_[View the full topic](https://www.virtocommerce.org/t/simple-logic-app-that-gets-20-orders/230)._
