Azure Logic Apps (With Demo Using YouTube and Outlook.com Connectors)
In this tutorial, we will build an Azure Logic App using the YouTube and Outlook.com connectors to be used in enterprise integration solutions.
Join the DZone community and get the full member experience.
Join For FreeIn this blog, we will build an Azure Logic App using the YouTube connector as a trigger and the Outlook connector as action.
Prerequisite
Microsoft Azure Subscription – Sign up for Azure Free account.
Basic knowledge of Azure Logic apps.
Zeal to learn.
Quick Overview
Logic Apps is an enterprise integration product offering from Microsoft Azure. It helps in building powerful integration business solutions. With a no-code model, Logic Apps automates data across cloud to on-premise, cloud to cloud, and on-premise to on-premise.
Logic Apps is a fully-managed iPaaS (Integration Platform as a Service) which scales up automatically when demands.
Connectors are an important part of Logic Apps workflows. Connectors are fully managed APIs given by.NET development services providers to communicate or act on user data in a workflow.
Connectors as Triggers execute or initiate workflows. Connectors as Actions are the ones which act on data received by the triggers.
Use Case
Here, we will build a business workflow basically implemented by the Media and Advertisement Domain.
Consider we have a client with a YouTube channel managed by a PR agency. Now, this agency is responsible for editing client videos, publishing the video over the channel, notifying any specific user, even, say, the client himself. Every time any video is published, the client should be notified about this.
To accomplish the above task, we will use:
YouTube connector as the Trigger.
Outlook.com connector as the Action.
Create the Logic App
Open Microsoft Azure Portal in the browser.
Click on New => Enterprise Integration => Logic App.
Enter the mandatory details:
Name – Name of the Logic App. For this article, we named it youtube-outlook-gmail-demo.
Subscription – Microsoft Azure Subscription.
Resource Group – Logic App being an Azure resource, it must be deployed under a Resource group, a logical grouping of Azure resources. Here, we have created a new resource group with the name youtube-outlook-gmail-demo.
Location – For this article, we selected West US. It’s not mandatory.
After entering all the required details, click on Create. This will create a new Logic App.
Open up the Logic App designer window for building workflows by adding triggers and connectors. It comes up with few predefined Templates associated with different connectors. As we need to build Workflows as per our scenario, select Blank Logic App Template.
As mentioned above, select YouTube Connector as the Trigger.
Enter YouTube in the search box. Select "When a video is uploaded by a channel," as we need to start our workflow when the video is published or uploaded to the client’s channel.
Authenticate with your Google account credentials. Click on "sign in."
Allow the required permissions after carefully reading all the details. These are the permissions required by Azure Logic App with a YouTube account.
Now, once its authenticated, we need to provide the YouTube channel ID of the channel. You can achieve this by navigating to the channel - it is displayed in the URL. Considering the below image as our YouTube channel, copy the Channel ID.
At Channel ID, you will get the list of all the channels your account is subscribed to! Along with the list, there will be an option saying, "Add Custom Value." Click on, "Add Custom Value." Paste the Channel ID from above, and enter it in the box.
Let’s go with the default check time interval: check-in every three minutes. We can also change the connection (Google account used to authenticate) by clicking on "Change connection link," as highlighted. Click on Save at the top left corner to save our workflow up to this step.
Next, add an action to react or respond to the trigger. In our use case, if a new video is published, we need to notify a specific person.
Here, our notification would be in the form of an email. So, for emailing, we will be using the Outlook.com connector as the action.
To add an action, click + New step => Add an action.
Enter Outlook.com in the search box.
Select Outlook.com and set the action as "Send an email."
Authenticate with your Outlook account credentials.
Click on "sign in."
Allow the required permissions after carefully reading all the details. These are the permissions required by Azure Logic App with an Outlook.com account.
Now we need to enter all the required details in the Outlook.com connector.
To – Email ID we need to send an email to.
Subject – Subject of email sent.
Body – Body of email sent.
Notice that the parameters used in filling up these details are from an earlier (YouTube connector) step in the workflow. You can use all the parameters from the connector from the earlier step with the following connectors.
Click on "Save."
Testing the Workflow
Upload a video file to the respective YouTube Channel.
Channel Name: Azure Demo
Video Title: ‘Demo: Learning Logicapp’
Video Link: https://youtu.be/9eUfimtpcdA
Click on Publish to upload the video.
Now, open Azure portal => Navigate to Logic Apps => Overview section.
All trigger history can be viewed under the Runs history section. Click on refresh to wait for the Trigger to execute, or click on Run Trigger. You can see that the new video added to the channel triggered the workflow, and the execution can be seen.
It took 2.74 seconds to complete the flow. Interesting!
Click on the listed result to view its details, step-by-step along with the time taken for each step in the workflow. You can click each connector tab to view the raw data request and response.
The details above say that the YouTube connector was triggered as we uploaded the video to the channel, and responded to an action by notifying the configured email ID via Outlook.com.
If the mailbox is seen, the way we configured mail with parameters can be seen below.
Our use case was successfully executed.
Summary
Without writing a single piece of code, we executed a business workflow integrating the YouTube API with the Outlook.com API, thus meeting our goal. With easy implementation and a simpler integrating designer tool, we were able to build and execute the workflow super fast.
I would recommend you try out these connectors for more interesting use cases in your organization, leveraging super cool Azure Logic App features.
Thank you!
Opinions expressed by DZone contributors are their own.
Comments