Getting M365 Admin Center info with the Graph API

Published Aug 16 2021 11:33 AM 2,799 Views
Frequent Contributor

I wrote the original message center to Planner integration using the Office 365 Communications API, but this has now moved over to the Graph API, and the older API will no longer be available past the end of the year.  The built-in Message Center to Planner will have no issues of course, but if you used my code, or the additional Service Health Dashboard code I added a while back then you will need to update.  The code now fully uses MSAL for authentication and Graph to read both Message Center and Service Health Dashboard data.  It didn't need much changing, but I did notice that the MC posts now have a new reference type of 'Roadmap ID' which I am not using and it broke my code as I was only expecting an external link.  I just filter for the external links for now, but I'll likely come back and add Roadmap info and hopefully tie this into details from the M365 Roadmap too.

The code can be found at LunchWithaLens/AdminCenterAutomation: Updated code to use MSAL, as well as simplifying to loop on pr... and I won't walk-through it here as the basics haven't changed since the last walk-through blog post.

The code does two things:

  1. The original message center to Planner sync - not as convenient as the built-in code, but useful if you need to push into different plans or assign to various different people.  This writes a queue entry for each workload then another Azure function pulls these off and writes to Planner

Message Center to Planner syncMessage Center to Planner sync

 

      2.  Pushes service incident data into Teams, and will also @mention someone too.  Subsequent updates will add to the thread.

Teams view of a service incidentTeams view of a service incident

This code might also be useful just to see how to write into a teams channel and a thread and @ mention.

I might get around to porting these to C# at some point, and I really ought to tidy up the posts that have HTML formatting in them too!

1 Comment
Occasional Contributor

Another great reason to learn Microsoft Graph!

%3CLINGO-SUB%20id%3D%22lingo-sub-2653539%22%20slang%3D%22en-US%22%3EGetting%20M365%20Admin%20Center%20info%20with%20the%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2653539%22%20slang%3D%22en-US%22%3E%3CP%3EI%20wrote%20the%20original%20message%20center%20to%20Planner%20integration%20using%20the%20Office%20365%20Communications%20API%2C%20but%20this%20has%20now%20moved%20over%20to%20the%20Graph%20API%2C%20and%20the%20older%20API%20will%20no%20longer%20be%20available%20past%20the%20end%20of%20the%20year.%26nbsp%3B%20The%20built-in%20Message%20Center%20to%20Planner%20will%20have%20no%20issues%20of%20course%2C%20but%20if%20you%20used%20my%20code%2C%20or%20the%20additional%20Service%20Health%20Dashboard%20code%20I%20added%20a%20while%20back%20then%20you%20will%20need%20to%20update.%26nbsp%3B%20The%20code%20now%20fully%20uses%20MSAL%20for%20authentication%20and%20Graph%20to%20read%20both%20Message%20Center%20and%20Service%20Health%20Dashboard%20data.%26nbsp%3B%20It%20didn't%20need%20much%20changing%2C%20but%20I%20did%20notice%20that%20the%20MC%20posts%20now%20have%20a%20new%20reference%20type%20of%20'Roadmap%20ID'%20which%20I%20am%20not%20using%20and%20it%20broke%20my%20code%20as%20I%20was%20only%20expecting%20an%20external%20link.%26nbsp%3B%20I%20just%20filter%20for%20the%20external%20links%20for%20now%2C%20but%20I'll%20likely%20come%20back%20and%20add%20Roadmap%20info%20and%20hopefully%20tie%20this%20into%20details%20from%20the%20M365%20Roadmap%20too.%3C%2FP%3E%0A%3CP%3EThe%20code%20can%20be%20found%20at%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FLunchWithaLens%2FAdminCenterAutomation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ELunchWithaLens%2FAdminCenterAutomation%3A%20Updated%20code%20to%20use%20MSAL%2C%20as%20well%20as%20simplifying%20to%20loop%20on%20products%20not%20tasks%20-%20hence%20fewer%20queue%20items.%20Also%20added%20a%20function%20for%20SHD%20posts%20into%20Teams%20channels.%20(github.com)%3C%2FA%3E%26nbsp%3Band%20I%20won't%20walk-through%20it%20here%20as%20the%20basics%20haven't%20changed%20since%20the%20last%20walk-through%20blog%20post.%3C%2FP%3E%0A%3CP%3EThe%20code%20does%20two%20things%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EThe%20original%20message%20center%20to%20Planner%20sync%20-%20not%20as%20convenient%20as%20the%20built-in%20code%2C%20but%20useful%20if%20you%20need%20to%20push%20into%20different%20plans%20or%20assign%20to%20various%20different%20people.%26nbsp%3B%20This%20writes%20a%20queue%20entry%20for%20each%20workload%20then%20another%20Azure%20function%20pulls%20these%20off%20and%20writes%20to%20Planner%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Planner.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303578iB2CFE68FACBC5AB8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Planner.png%22%20alt%3D%22Message%20Center%20to%20Planner%20sync%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EMessage%20Center%20to%20Planner%20sync%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%202.%26nbsp%3B%20Pushes%20service%20incident%20data%20into%20Teams%2C%20and%20will%20also%26nbsp%3B%40mention%20someone%20too.%26nbsp%3B%20Subsequent%20updates%20will%20add%20to%20the%20thread.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TeamsView.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303579iF130FE782EB09B39%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TeamsView.png%22%20alt%3D%22Teams%20view%20of%20a%20service%20incident%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ETeams%20view%20of%20a%20service%20incident%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20code%20might%20also%20be%20useful%20just%20to%20see%20how%20to%20write%20into%20a%20teams%20channel%20and%20a%20thread%20and%26nbsp%3B%40%20mention.%3C%2FP%3E%0A%3CP%3EI%20might%20get%20around%20to%20porting%20these%20to%20C%23%20at%20some%20point%2C%20and%20I%20really%20ought%20to%20tidy%20up%20the%20posts%20that%20have%20HTML%20formatting%20in%20them%20too!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2653539%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20built-in%20sync%20to%20Planner%20in%20the%20Message%20Center%20is%20great%2C%20but%20there%20are%20still%20times%20when%20you%20might%20want%20to%20craft%20your%20own%20sync%20-%20and%20there%20is%20also%20the%20Service%20Health%20Data%20that%20is%20useful.%26nbsp%3B%20Very%20recently%20the%20API%20moved%20over%20to%20Graph%2C%20so%20I%20took%20the%20opportunity%20to%20update%20my%20code%20and%20fix%20a%20few%20bugs%20too.%26nbsp%3B%20Read%20on%20for%20more%20details...%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AdminCenterGraphAPI.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303576i060FF88A017E9F45%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22AdminCenterGraphAPI.gif%22%20alt%3D%22Things%20to%20do%20with%20Graph%20and%20the%20Admin%20Center%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EThings%20to%20do%20with%20Graph%20and%20the%20Admin%20Center%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2655568%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20M365%20Admin%20Center%20info%20with%20the%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2655568%22%20slang%3D%22en-US%22%3E%3CP%3EAnother%20great%20reason%20to%20learn%20Microsoft%20Graph!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎Aug 16 2021 11:33 AM
Updated by: