Introduction:
There are different types of sites in SharePoint Online like Office 365 Group SharePoint site connected with MS Teams, Office 365 Group SharePoint site connected with Yammer and Communication site. When you migrate contents into an existing SharePoint site there are some situations when you have to determine the migration process based on the target SharePoint site type. Suppose we want to migrate the discussions or question and answers into a SharePoint site, now if it is a Yammer connected SharePoint site, we will migrate the discussions into Yammer and if it is a MS Teams connected SharePoint site, we will post the discussions into MS Teams channel. So, before migration we have to check and validate the target SharePoint site type.
In a recent Jive to Office 365 migration project we had a requirement to validate an existing SharePoint site within Power Apps. We have to validate whether the site URL is valid SharePoint site URL or not. We also need the determine the SharePoint site type, whether it is a SharePoint Communication or SharePoint Team Site or Yammer connected SharePoint Site or Microsoft Teams Connected SharePoint site.
This post presents an artefact where I used Azure App and MS Graph API’s in Microsoft Flow to get the site details.
There are 3 main steps in this process.
- Register an Azure App.
- Create Flow to get the site details using Microsoft Graph API.
- Run the flow from Power Apps.
Azure app registration process
- Login to https://portal.azure.com/#home and register an azure app with the following permissions,
- Once Admin consent is granted share the following information of the app
- Application (client) ID
- App Client secrets
- Directory (tenant) ID
Create a Microsoft Flow to get the SharePoint site details
We will be creating this flow from blank. As a best practice when creating a flow, start by adding the steps for the trigger and the final action.
In flow we use below endpoints to get the details
The following steps explain the implementation step by step.
The details of the sample schema is given below.
Sample Schema for Parse JSON
{
"type": "object",
"properties": {
"token_type": {
"type": "string" },
"expires_in": {
"type": "integer" },
"ext_expires_in": {
"type": "integer" },
"access_token": {
"type": "string" }
}
}
The following is the sample schema for SiteDetails.
Sample Json for – “Parse JSON SiteDetails”
{
"type": "object",
"properties": {
"@@odata.context": {
"type": "string"
},
"createdDateTime": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"lastModifiedDateTime": {
"type": "string"
},
"name": {
"type": "string"
},
"webUrl": {
"type": "string"
},
"displayName": {
"type": "string"
},
"root": {
"type": "object",
"properties": {}
},
"siteCollection": {
"type": "object",
"properties": {
"hostname": {
"type": "string"
}
}
}
}
}
Now save the flow with a valid name. I saved it as “GetSharePointSiteType”.
Ebook : 10 most important issues and how to solve them when migrating to SharePoint Online today!
Whether you are a business leader, IT professional, or end-user, the Netwoven SharePoint migration eBook can educate you on the benefits and opportunities of migrating to SharePoint on the cloud. Download it today!
Get the eBookNow it’s time to test the flow created.
- In the Flow Designer, just click on “Test” button.
- A panel called “Test Flow” will slide out from the right. Select “I’ll perform the trigger action.” And click on “Save & Test” button.
A dialog will appear asking you to enter value for SitemailNickname which you get from a site URL(last part of the URL). For example, if the site URL is https://mydomain.sharepoint.com/sites/DemoSite then enter “DemoSite” as a SitemailNickname.
In PowerApps we will pass this as a parameter to run the flow.
- Now click on “Done” button and see the response to see the site type.
Run the above created flow from Power apps
Design the PowerApps screen as bellow to run the flow
- On “Verify site” button “OnSelect” property write the below Set functions and call the flow
- Set(ExistingSiteMailNickname,Substitute(TextExistingSharePointURL.Text,”https://mydomain.sharepoint.com/sites/”,”” ));
- Set(ExistingSharePointSiteType, GetSharePointSiteType.Run(ExistingSiteMailNickname)));
- On “LabelSharePointSiteType” label “Text” property set ExistingSharePointSiteType.sharepointsitetype
Now if you enter a Yammer connected SharePoint site (which is also a Microsoft 365 connected group site)URL flow will return “YammerProvisioning” as a group type.
If you enter a Microsoft Teams connected SharePoint site URL flow will return “Team” as a group type.
If you enter a Communication site URL flow will return “SharePoint”.
If you enter an invalid URL flow will return “Invalid Site URL”.
Conclusion
I hope you enjoyed this quick tutorial and learned how to use Azure App and Microsoft Graph API inside Microsoft Flow in Office 365 to get the SharePoint Site type and other properties of the group sites. In a real-life migration project, it would be necessary to automate such validations and can easily be done just by extending the given snippets within an appropriate job.
Please feel free to comment or connect back should you need any clarifications.