In this post we create a simple Azure Logic App, that will authorize to VC3 Platform and get 20 orders.
- An Azure subscription. If you don’t have an Azure subscription, sign up for a free Azure account.
- Azure Logic Apps Tools for Visual Studio: 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:
After you fill-in name for the application, it will ask for the certain project template. Choose “Logic App”:
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):
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:
Here you can get query uri and apiDefinitionUrl:
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
Now, you can see full logic app workflow in the designer: Logic App Designer
Our application is ready to deploy!
Step 7. Deploy Logic App to Azure
Right-click on project -> Deploy -> New Deploy
Click deploy, and see the window Edit Parameters open. Fill-in needed parameters, click Save:
After that, you can go to Azure portal and see the Logic App run history:
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).