Introduction
Hello Everyone,
Welcome again to the Power Guide Mentorship Program.
I hope you and your loved ones are doing well and are in good health.
This pandemic and resulted isolation have made us turn to technology, to stay connected with our friends and colleagues in ways that we never imagined.
Almost overnight, video conferencing and digital collaboration have become a big part of our daily life and work. With COVID-19 continuing to impact people and countries around the world, Every organization encouraging our teams to work from home as much as possible, as are many organizations in this region. And they expect this trend to continue across the world.
During this tough time, Microsoft\’s top priority is the health and safety of employees, customers, partners, and communities. And they are promoting and encouraging everyone to Microsoft Teams for all kinds of collaborations and communications use.
By making Microsoft Teams available to as many people as possible, Microsoft aims to support public health and safety by keeping teams connected while they work apart.
Everyone around the world is now working, learning, and connecting with colleagues, friends, and family through the power of technology. From kitchen tables to living room couches, and from home offices doubling as home schools—people are relying on Microsoft Teams to work and learn.
Businesses large and small are depending on Teams for mission-critical work. First responders are using Teams to communicate when lives depend on it. Governments are turning to Teams to move medical supplies to where they are needed most. Doctors and nurses are using it to consult with patients, and researchers are collaborating on it across continents to find a vaccine. And teachers are using Teams to teach students in entirely new ways. Important moments of human connection, achievement, and celebration have all moved online.
Hence, having a smooth Integration of Microsoft Teams with Microsoft Dynamics 365 and Power Platform is one of the most common requirement these days.
This article focuses on – Automate of Microsoft Teams Provisioning with various Microsoft and Non-Microsoft Products so that every user who is sitting at any corner in the world, could collaborate, connect, and communicate with each other online with ease.
Today, In this article I am going to share the information about the Automation of Microsoft Teams Provisioning and it\’s Integration with PowerApps and PowerApps Portal.
Business Challenge
Let me first explain my business use case that pushed me to think about implementing this feature:
Being an Ambassador of 365 Saturday (World largest MVPs Community), we organize many training, webinars, and events worldwide. However, from the last few months due to the COVID-19 lockdown, we have been organizing these events online (almost every weekend) via Microsoft Teams.
Hence, being an Organizer or Admin of the Event, we all have pressure to organize and manage these events online in the most effective and efficient manner.
Since we are using Microsoft Teams for all online Events, We have been doing the following activities manually almost every weekend:
- Create a new Team for a new Event.
- Add all the Event Organizers and Admin as a Team Owner
- Add all the Attendees as Guest Team Members (Outside or Internal Users)
- Send a Team Invitation (Meeting) to all the participants along with the Event Schedule.
- Remove/Delete the Team once the Event is finished (Optional).
- Microsoft Dynamics 365
- Power Automate
- PowerApps Portals/PowerApps
- Microsoft Graph APIs
- Azure Portal
- Microsoft Graph Explorer
- Dynamics 365 License/Trial
- Power Automate License/Trial
- Azure Subscriptions/Trial
- Global Admin Rights on Azure Active Directory
- In Dynamics 365, I have Event, Organiser, and Attendee (Event Registration) Entities.
- Event and Attendees have 1:N relation, which means an Event could have multiple attendees.
- Organizer and Event have 1:N relation, which means one Organizer could host multiple events.
- I have a Boolean field on Event – \”Publish to Teams\”, which publish an event on PowerApps Portals and Automate Teams configuration in Microsoft Teams
- I have a PowerApps Portal, which displays all the Events along with Event\’s Agenda, Speakers, and Registration option to allow Attendees to Register for a particular Event,
- Once an Organiser Publish the Event (set Publish to Team field\’s value to true), a new Teams should get created in Microsoft Teams with the same name as Event Name.
- The Organizer of that event should get added as the Owner of that Team.
- And, all the Attendees of that Event should get added as a Guest Members of that Team,
- Create a Team Meeting and Send the Meeting Invitation link to all the Event Participants.
Before proceeding with solution design, I would like you to know a few fundamental concepts of Microsoft Teams, which is very useful from the developer perspective. Can have a look at this article.
- Microsoft Teams allow anyone with a business or consumer email accounts, such as Outlook, Gmail, or others, can participate as a guest in Teams.
- In order to add any Guest User (that doesn\’t belong to your organization) in Microsoft Teams, you can add them manually in Teams as well. however, to automate this process, these users need to be added in Azure AD as a Guest Users
- Owner/Admin of the Team must be a licensed Azure AD User
- Guest Team members are not necessarily to be a licensed Azure AD User. They could be Guest Azure AD Users as well.
- As an admin, you can add a new guest user to the organization in a couple of ways.
- Global admins or Teams admins and team owners add a guest to a team in the Teams clients or in the Teams admin center
- Add guests to your organization through the Azure Active Directory (Azure AD) B2B collaboration.
- Azure AD – To Register an Azure Application, so that we can call and authenticate Microsoft graph API
- Microsoft Graph API – To perform an operation in Azure AD and Microsoft Teams
- Azure AD – Retrieve/Create and get Access Token of Azure AD User
- Microsoft Teams – Create Team, Add Team Owner, Add Guest Team Member and Create Teams Meeting
- Dynamics 365 – Data Source, which will pass all relevant information to Power Automate, like Team Name, Team Owner, Team Members, etc
- Power Automate – Trigger on a particular event and Pull the information from Data Source (like D365) and automate the Team Creation, Adding Team Owner, Adding Team Members, and Send Team Invites to all participants
5. In the left panel, click Overview. Copy the Application (client) ID and Directory (tenant) ID values. These values will be used in Flow for authentication.
11. Click Application Permission and Add the following Permissions (Add permission based on your need).
I have added the following Application and Delegate Permission based on my Requirements and the operations I need to perform using Microsoft Graph API.
Sub Steps of Step 26 (26-1 to 26-8)
Sub Steps of Step 26-7 (26-7-1 to 26-7-7)
Sub Steps of Step 29 (29-1 to 29-3)
Sub Steps of Step 30 (30-1 to 30-2)
Explanation of each Power Automate Step
Microsoft Graph API
I know this article is a bit complex and hard to understand from a beginner\’s perspective. Because I have used so many Advanced features of Power Automate and other Azure components. But trust me, the intension of writing this article is not only to demonstrate the Power of Power Platform but also to showcase the capabilities of Microsoft Graph API, which is very useful nowadays in many requirements.
Let me explain some fundamental concepts of Microsoft Graph API…
What is Microsoft Graph API?
If we have to perform any operation in Dynamics 365 either from within the CRM Application like forms and views, through JavaScript, Plugin, Workflow, C# code, or through any language, Microsoft has given one Rest API called – Dynamics 365 WEB API (Enhanced version of Organisation Service or OData). And that API is only restricted to perform operations in Dynamics 365 only.
However, you already know that Microsoft Dynamics 365 is tightly coupled with numerous other Microsoft products and services like Microsoft Azure, Microsoft Teams, Office 365. Outlook, OneDrive, OneNote, Microsoft Excel, and many more. And we often need to interact with these products and services to fulfill various business needs.
Hence, in order to interact with all these products and services, Microsoft introduced a new Rest API called Microsoft Graph API, which enables you to access various Microsoft Cloud service resources.
Why we call this API as Graph API?
The Graph API is named after the idea of a \”social graph\” — a representation of the information on Facebook. It\’s composed of nodes — basically individual objects, such as a User, a Photo, a Page, or a Comment.
What are the capabilities of Microsoft Graph API?
Microsoft Graph exposes REST APIs and client libraries that provide a Gateway 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
Are there any pre-requisites that need to be taken care of before consuming Microsoft Graph API?
- You need to have Azure Subscription
- You need to Register an Application in Azure. Capture its ClientID, SecreTKey, and Tenant ID.
- After you register your app and get authentication tokens for a user or service, you can make requests to the Microsoft Graph API.
Which language I can used to play with Microsoft Graph API?
Microsoft Graph API supports CORS, which means it is a Platform and Language-Independent API. Few languages that can be used to consume Microsoft Graph API are:
ASP.NET, C#, JAVA, Node JS, Android, Angular, Javascript, IOS, PHP, Python, React, Ruby, and many more.
What is the syntax of Microsoft Graph API?
Here is the syntax of Graph API-
{HTTP method} https://graph.microsoft.com/{version}/{resource}?{query-parameters}
Here,
HTTP method – GET, POST, PUT, PATCH, DELETE, etc
Version – Microsoft Graph currently supports two versions: v1.0 and beta. The v1.0 version includes generally available APIs. Use the v1.0 version for all production apps. The beta includes APIs that are currently in preview.
Query Parameter – Same like you use the query parameter and query in ODATA and D365 Web API
For Example – Below is the syntax of Microsoft Graph API to retrieve Azure AD user by Email Address
GET https://graph.microsoft.com/v1.0/users?$select=id,mail&$filter=mail eq \’arpit@dynamics.community\’
Any Tool, where I can test the Request and Response of Microsoft Graph API?
Microsoft Graph Explorer is a web-based tool that you can use to build and test requests using Microsoft Graph APIs. You can access Microsoft Graph Explorer at
https://developer.microsoft.com/graph/graph-explorer.
Postman is also a tool that you can also use to build and test requests using the Microsoft Graph APIs. You can download Postman at
https://www.getpostman.com/
I would recommend going with Microsoft Graph Explorer, as it is more informative and user friendly from a troubleshooting perspective.
Can I consume Microsoft Graph API in Dynamics 365 Plugins, Custom Workflow, etc?
Yes, it is possible. Since Graph API can be consumed through C# code, therefore you can write the same logic in Plugin also.
Can we call Microsoft Graph API from PowerApps Portals? Tell me with Real-Time Example?
Yes, it is possible. You can call Microsoft Graph API from PowerApps and Dynamics 365 Portals.
You can pass Input Parameters from Portal to Power Automate. Power Automate can call the Graph API and return the response back to PowerApps Portals. (Can refer my previous article for this)
If your organization is restricted to use Power Automate, you can also use Plugin, C# Code or JavaScript to perform the operations.
Real-Time Example – In PowerApps Portal, Microsoft is planning to deprecate the Local Authentication feature and recommend to use Azure AD B2C as a default Portal Authentication option.
Azure AD B2C users are the Guest AD Users created in Azure Active Directory, which doesn\’t require an AD license
Now, In order to interact with these Azure AD B2C Users from Dynamics 365 or Portals, we don\’t have other option except Microsoft Graph API to perform the following activities:
- To change the user\’s contact details in Azure like email, contact number, name, etc.
- To automate the user creation in Azure AD from Dynamics 365 and Portal
- To map existing D365 contacts with Azure AD B2C users.
- To manage the Invitation process for Azure AD B2C users.
- Automatically create username and password for Azure B2C users
Now, let\’s see how we have used Microsoft Graph API in Power Automate in our requirement
To Interact with Azure AD:
- Retrieve Azure AD User details (like Unique Id, UserType, etc) by Email Address.
- Create a Guest user in Azure AD, if the user is not already present.
- Get Acces Token of Azure AD User
To Interact with Microsoft Teams:
- Create a new Team in your Microsoft Teams
- Add Team Owner (must be Azure AD Member, not Guest User)
- Add Team Members (must be either Azure AD Member or Guest user)
Let\’s have a look, how we have consumed Microsoft Graph API in Power Automate
![]() |
Retrieve User from Azure AD based on Email Address |
![]() |
Create a Guest User in Azure AD without sending an Invitation |
![]() |
Create a new Team with name – Power Guide Mentorship |
![]() |
Create a Team Meeting |
![]() |
Get Access Token of Azure AD User to authenticate Microsoft Graph API |
![]() |
Add Team Owner |
![]() |
Add Team Members as Guest Team Members |
I hope this article helps you to Automate your Team\’s Provisioning.
That\’s all folks for today. Stay tuned for more updates.
Stay Safe and Take Care !!
Cheers
Microsoft | ERP | Support | Services | Implementation | Migration | Dynamics | Upgradation
LikeLike
Hello thanks for the great post! could you help me further with everything after the \”Power Automate Configuration\” section? we manage many schools which we have moved to Teams and this would be off great use!thanks in advance.Matt
LikeLike
Taskade – DEV Communityremote work blogremote team blogwork from home blogrealtime organization blogrealtime collaboration blogTaskade is the unified workspace for distributed teams. Chat, organize, and get things done.
LikeLike
Thanks for sharing this helpful & wonderful post. I really appreciate your hard work. this is very useful & informative for me.dynamics 365 portal
LikeLike
This concept is a good way to enhance the knowledge.thanks for sharing.. Great article Microsoft Dynamics AX TrainingMS Dynamics AX TrainingMS Dynamics Training in HyderabadMicrosoft Dynamics AX Technical TrainingMicrosoft Dynamics AX Technical Training in HyderabadMS Dynamics Technical Online TrainingMS Dynamics AX Technical Training in HyderabadMS Dynamics AX Online TrainingD365 AX Online Training
LikeLike
Valuable post useful for everyone.Keep on sharing.D365 Finance and Operations TrainingD365 Finance and Operations Training in HyderabadD365 Operations Training
LikeLike
Great Post Arpit. I am trying on my side as well. Keep Posting
LikeLike
One of the best post, I have gone through on this topic in recent past. Keep it up !!
LikeLike
I appreciated your work very thanks Microsoft Dynamics 365 Business Central Credit Card Processing
LikeLike
It is getting popularity day by day. It is informative. such a nice blog! microsoft office 365 training
LikeLike
Earnings mostly leading good quality goods — you'll be able to recognize all within just: [pii_email_8079047078567379049d]
LikeLike