Search
StarWind is a hyperconverged (HCI) vendor with focus on Enterprise ROBO, SMB & Edge

Using Graph API with Azure Logic Apps

  • July 21, 2020
  • 11 min read
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.

Azure Logic Apps

Building applications automatically becomes more and more important in order to save time, increase productivity, and automate different activities. You can use different ways to achieve these goals, and for instance, you could use scripting. But if you are not familiar with scripting, you may want to use another way to perform automation. With Azure Logic Apps, you can automate and orchestrate your infrastructure or application deployment without writing a single line of code.

What Is Azure Logic Apps?

Azure Logic Apps is a cloud service that helps you schedule, automate, and orchestrate tasks, business processes, and workflows when you need to integrate apps, data, systems, and services across enterprises or organizations

While Logic Apps offers hundreds of connectors, in this guide, we will use 5 connectors:

1 – Schedule

  • Run a logic app on a specified recurrence, ranging from basic to advanced schedules with the Recurrence trigger.
  • Run a logic app that needs to handle data in continuous chunks with the Sliding Window trigger.
  • Pause your logic app for a specified duration with the Delay action.
  • Pause your logic app until the specified date and time with the Delay until action.

2 – Variables

  • Append to array variable: Insert a value as the last item in an array stored by a variable.
  • Append to string variable: Insert a value as the last character in a string stored by a variable.
  • Decrement variable: Decrease a variable by a constant value.
  • Increment variable: Increase a variable by a constant value.
  • Initialize variable: Create a variable and declare its data type and initial value.
  • Set variable: Assign a different value to an existing variable.

3 – HTTP

  • Call HTTP or HTTPS endpoints with triggers and actions for HTTP. Other HTTP built-in triggers and actions include HTTP + Swagger and HTTP + Webhook.

4 – Data Operations

  • Compose: Create a single output from multiple inputs with various types.
  • Create CSV table: Create a comma-separated-value (CSV) table from an array with JSON objects.
  • Create HTML table: Create an HTML table from an array with JSON objects.
  • Filter array: Create an array from items in another array that meet your criteria.
  • Join: Create a string from all items in an array and separate those items with the specified delimiter.
  • Parse JSON: Create user-friendly tokens from properties and their values in JSON content so that you can use those properties in your workflow.
  • Select: Create an array with JSON objects by transforming items or values in another array and mapping those items to specified properties.

5 – Office 365 / Outlook

  • Connect to your Office 365 email account so that you can create and manage emails, tasks, calendar events and meetings, contacts, requests, and more.

What Is Microsoft Graph?

Microsoft Graph exposes REST APIs and client libraries to access data on the following Microsoft 365 services:

  • Office 365 services: Delve, Excel, Microsoft Bookings, Microsoft Teams, OneDrive, OneNote, Outlook/Exchange, Planner, and SharePoint
  • Enterprise Mobility and Security services: Advanced Threat Analytics, Advanced Threat Protection, Azure Active Directory, Identity Manager, and Intune
  • Windows 10 services: activities, devices, notifications
  • Dynamics 365 Business Central

Getting Started

In this guide, we will use Microsoft Graph API + Azure Logic Apps to orchestrate and automate the creation of a Teams meeting.

Open the Azure Portal, and search ‘Azure Logic Apps’ in the search bar. Then create your first Logic Apps

Azure Logic Apps

Go to Azure Active Directory, and add a new ‘App registration

Azure Active Directory

Enter the name of the application and who can use the application or access the API.

Enter the name of the application

Then go to ‘API permissions’ and select ‘Microsoft Graph

Microsoft Graph

Select ‘Application permissions’ instead of Delegated permissions. App permissions will allow your application to run without authentication popup.

Application permissions

Next, click ‘Grant admin consent’ to call APIs

Grant admin consent

Go to the ‘Certificates & secrets’ section and add a new client secret

Certificates & secrets

Now, open the Logic Apps designer, and start the workflow with the ‘Recurrence’ trigger. In my case, I want to run the workflow on a daily basis, but you may want to run the workflow on another trigger. Then add ‘variable’ action, it is not mandatory, but if you work with a lot of steps in your workflow, it could be better to store information in variables. In my case, I store the Application ID, Tenant ID and the secret:

wp-image-14895

Now add ‘HTTP’ action and select ‘POST’ method. The following information is available and very well documented on the Microsoft documentation website: https://docs.microsoft.com/en-us/graph/api/application-post-onlinemeetings?view=graph-rest-beta&tabs=http.

In order to use the secret that we created previously, you must select the ‘Active Directory OAuth’ authentication type

Active Directory OAuth

Now, we need to parse the HTTP response with the ‘Parse JSON’ action. You may already know the HTTP response but if not, run the workflow to check the response. Copy/paste the response and go back to edit the workflow.

Then click ‘Use sample payload to generate schema’ and paste the HTTP response. It will automatically create the JSON schema. Then, I added a ‘variable’ action but it is not mandatory

Parse JSON

In my case, I want to send the URL by email to the attendees, so add the ‘Send an email’ action

‘Send an email’ action

Save the workflow and run it. After running the workflow, all the steps must be checked with a green mark

Save the workflow

And then you should receive immediately the email with your Teams invitation link

Teams invitation link

Conclusion

Thanks to Azure Logic Apps, you can easily automate and orchestrate your deployment and business use cases. Logic Apps will help you to save time and increase your productivity. Azure Logic Apps pricing can be found on the following page: https://azure.microsoft.com/en-us/pricing/details/logic-apps/

Hey! Found Nicolas’s article helpful? Looking to deploy a new, easy-to-manage, and cost-effective hyperconverged infrastructure?
Alex Bykovskyi
Alex Bykovskyi StarWind Virtual HCI Appliance Product Manager
Well, we can help you with this one! Building a new hyperconverged environment is a breeze with StarWind Virtual HCI Appliance (VHCA). It’s a complete hyperconverged infrastructure solution that combines hypervisor (vSphere, Hyper-V, Proxmox, or our custom version of KVM), software-defined storage (StarWind VSAN), and streamlined management tools. Interested in diving deeper into VHCA’s capabilities and features? Book your StarWind Virtual HCI Appliance demo today!