Skip to main content

Using Microsoft Graph Open Extensions with PowerApps

This blog will cover how to create a lightweight application that will Create, Read, Update and Delete user profile data in Microsoft Graph by extending the “user” resource.

Firstly, let us cover what exactly Graph Extensions are.

Graph Extensions allow us to extend several graph resources, such as “user” and “message”, to capture additional data that we may need for our own application, without having to rely on an external data source.

One benefit of using Graph Extensions over methods such as local storage is the roaming capability. Also, because the application properties are stored in the Graph, they can be leveraged across the whole Microsoft 365 platform.

Because I am an aviation geek we will use “favorite aircraft” as an example scenario. Here is the high-level objective.

  • A user can create, read, update and delete a property named “plane”
  • The selection is saved as an extended property in the Microsoft Graph.

Getting started

Because we are interacting with the Microsoft Graph, we need to set-up an application registration in Microsoft Azure where we can define settings such as API permissions.

Application Registration

Open Microsoft Azure and navigate to “Azure Active Directory”.

Click on “App registrations” and then select “New registration”.


Input a name for the application and select “Accounts in this organizational directory only”.


Within the redirect URI field input “https://global.consent.azure-apim.net/redirect” before clicking “Register”.


Once the application registration has been created, copy the “Application (client) ID” for later use.


Generate a “client secret” that never expires and copy the value for later use.




Within the API permissions add “User.ReadWrite” as a delegated permission from the Microsoft Graph.


Two permissions should now be listed:

  • User.Read
  • User.ReadWrite

Click on “Grant admin consent for *Org Name*


That should be everything we need to do within Microsoft Azure, next navigate to PowerApps.

Custom Connectors

Expand the “Data” navigation drop-down and select “Custom Connectors”.


Click on “New custom connector” followed by “Create from blank”.

Input a name and then click on “Continue”.


What follows are four different areas for configuration; General, Security, Definition and Test.

General

Within the “Host” field insert “graph.microsoft.com”.

Security

Within the “Authentication type” drop-down, select “OAuth 2.0” and then select “Azure Active Directory”.

Insert the “Client id” and “Client secret” we copied from the previous steps.

Within the “Resource URL” insert “https://graph.microsoft.com”.


Definition

Within the definition area we will create four actions for Create, Read, Update and Delete.

The Microsoft Graph Explorer is a great resource for simulating API calls and anticipating the responses. This tool is particularly useful for the following section, therefore please test each API call here before creating the following actions.

Create

Click on “New action”.



Give the action a “Summary”, “Description” and “Operation ID”.

Summary

Create Favorite Plane

Description

Create Favorite Plane

Operation ID

CreateFavoritePlane



Within the “Request” section click on “Import from sample” and copy the following values.


Verb

POST

URL

/v1.0/me/extensions

Headers

 

Body

{

    "@odata.type": "microsoft.graph.openTypeExtension",

    "extensionName": "com.bestranet.roamingSettings",

    "plane": "Concorde"

}

 


Within the toolbar click on “Create connector”.


You should now be able to test the action. To test the action, you will need to use a connection. If there are no existing connections, the custom connector may close to establish one. If this is the case, simply re-open the custom connector.

Read

Click on “New action”.



Give the action a “Summary”, “Description” and “Operation ID”.

Summary

Read Favorite Plane

Description

Read Favorite Plane

Operation ID

ReadFavoritePlane



Within the “Request” section click on “Import from sample” and copy the following values.


Verb

GET

URL

/v1.0/me?$select=id,displayName&$expand=extensions

Headers

 

 


Within the “Response” section click on “Add default response” and copy the following values.


Headers

 

Body

Paste from the response issued in Microsoft Graph Explorer




Within the toolbar click on “Update connector”.



You should now be able to test the action.

Update

Click on “New action”.



Give the action a “Summary”, “Description” and “Operation ID”.

Summary

Update Favorite Plane

Description

Update Favorite Plane

Operation ID

UpdateFavoritePlane



Within the “Request” section click on “Import from sample” and copy the following values.


Verb

PATCH

URL

/v1.0/me/extensions/com.bestranet.roamingSettings

Headers

 

Body

{

    "plane": "Concorde"

}



Within the toolbar click on “Update connector”.



You should now be able to test the action.

Delete

Click on “New action”.



Give the action a “Summary”, “Description” and “Operation ID”.

Summary

Delete Favorite Plane

Description

Delete Favorite Plane

Operation ID

DeleteFavoritePlane



Within the “Request” section click on “Import from sample” and copy the following values.


Verb

DELETE

URL

/v1.0/me/extensions/com.bestranet.roamingSettings

Headers

 

Body

 



Within the toolbar click on “Update connector”.


You should now be able to test the action.

Assuming all four CRUD actions within the custom connector have been successfully tested we may now proceed to create the canvas app.

Canvas App

Create and configure a canvas app that contains four buttons, a combo box control and a label.


Associate the custom connector we created previously as a data source to the app.

Configure each of the controls as follows.

Combo Box

Control Name

FavoritePlaneChoice

Items

["Concorde","Jumbo Jet","Bi Plane"]

SelectMultiple

false

IsSearchable

false

NoSelectionText

Favorite Plane

Label

Control Name

FavoritePlaneLbl

Text

"My Favorite Plane is " & First(favoritePlane.extensions).plane & "!"

 Button 1

Control Name

CreateFavoritePlaneBtn

Text

Create Favorite

OnSelect

GraphExtensionConnector.CreateFavoritePlane({'@odata.type':"microsoft.graph.openTypeExtension", extensionName:"com.bestranet.roamingSettings", plane:FavoritePlaneChoice.Selected.Value})

 Button 2

Control Name

ReadFavoritePlaneBtn

Text

Read Favorite

OnSelect

Set(favoritePlane, GraphExtensionConnector.ReadFavoritePlane({'$select':"id, displayName", '$expand': "extensions"}))

 Button 3

Control Name

UpdateFavoritePlaneBtn

Text

Update Favorite

OnSelect

GraphExtensionConnector.UpdateFavoritePlane({plane:FavoritePlaneChoice.Selected.Value})

 Button 4

Control Name

DeleteFavoritePlaneBtn

Text

Delete Favorite

OnSelect

GraphExtensionConnector.DeleteFavoritePlane()


Finally, play the app!

Assuming everything works correctly you should be able to Create, Read, Update and Delete your favorite plane from the Microsoft Graph as an extended property. Try from multiple devices and you will see the property roams with you, whichever device is used.

Although this blog is more centred towards PowerApps, the custom property we created for favorite plane can now be leveraged from multiple areas of the Microsoft 365 platform.

Perhaps my next blog will be using a SPFx web part to display this property on SharePoint.

Comments

  1. I liked your work and the way in which you have shared this article here about Microsoft 365 Power Automate. It is a beneficial and helpful article for us. Thanks for sharing an article like this. Keep it up.

    ReplyDelete
  2. 888casino Review and Bonus Code for 2021
    The 888 Casino 충청남도 출장안마 Review: 김포 출장안마 The Ultimate Guide 제천 출장안마 to 888casino. Check out the Games, Bonuses, Payments and Security; Deposit Limits; Software; Software  Rating: 제주 출장샵 3.8 · ‎Review by Dr 서울특별 출장샵

    ReplyDelete
  3. Euro Palace designed lots of its online slots to resemble conventional slots from the early 1800s. For instance, the Reel slots sport provides a simplistic design with cherries, gold bars, and 7s that take you again to much less complicated} time. What makes Ruby Fortune probably the greatest locations half in} online slots is its respected customer support staff and safe encryption. Royal Vegas certainly one of the|is amongst the|is likely one of the} finest online playing sites for those who|for many who|for individuals who} practice accountable playing. By using the "Responsible Gaming Features" on the login web page, players can set up deposit limits on a monthly 카지노사이트 or weekly foundation. This function also lets you set deadlines half in} and taking breaks.

    ReplyDelete

Post a Comment

Popular posts from this blog

Replace Power Automate Approval Emails with Adaptive Cards in Microsoft Teams

Microsoft recently released a personal app for Approvals within Teams. Please review this before investing time implementing something customized. If you are still interested in creating a custom adaptive card for an approval process check out the following blog for which this blog is a good precursor. With Microsoft Teams becoming an increasingly dominant force in collaboration, and one objective being the reduction of email, this blog covers how you can simply replace approval email notifications with dynamic adaptive cards in Teams. So, how does it work? I have created a sample SharePoint list using the “ Travel requests ” template and associated it with my Team as shown below. Within Microsoft Power Automate I have created an “ Automated cloud flow ” using the “ When an item is created ” trigger. The next step is to add the “ Create an approval ” action. I have personally configured this action as follows. Notice how I have set the “ Enable notifications ” to “ No ”. This wil

Customize list forms in SharePoint with JSON formatters

Back in the days of classic SharePoint we had a few options to customize list forms, such as JSLink. Up until recently our options to customize list forms in modern SharePoint were somewhat limited. Sure, we could use JSON to apply custom formatting to views and columns, but unless we leveraged tools, such as PowerApps or SPFx Application Customizers, it was impossible to style list forms. Microsoft has recently introduced JSON formatters for list forms and I think they are great, especially for requirements where a simple header or footer change may be required. In this blog we will cover what JSON formatters are, how we can leverage them and some useful examples to support our understanding. What are JSON formatters? When Microsoft introduced the modern version of SharePoint, capabilities like JSLink were no longer compatible and became obsolete. JSLink was useful because it allowed us to customize list views, forms and columns, and for some time there was a void until Micros

Create Customized Adaptive Cards for Power Automate Approvals in Microsoft Teams

Microsoft recently released a fantastic new feature with which we can action approval requests directly in Teams. This is great news, and no doubt moves us further away from the days of having to trawl through our email to locate an old approval request. But, what customization options are available for approval requests? Can we change the way these look? And can we create our own version of the approval adaptive cards? This blog covers how you can create a customized version of the adaptive card for Power Automate approvals. So, how does it work? Firstly, we need to look at the json payload that generates the out-of-the-box approval adaptive card. This can be extracted by initiating a variable of type string and then adding and configuring a “ Create an approval ” action. We will then set the value of our variable to “ Teams Adaptive Card”. Our flow should look like the following If we now test run the flow and check the value of our variable, we should see the json payload in the &q