A huge thank you to the attendees, organizers, volunteers, sponsors, and anyone else involved with M365 Twin Cities. This was my first community conference in 3+ years but it was amazing to share more about Microsoft Graph in my two sessions. I appreciate all of the attendees who joined and had great questions and engagement.
Below are PDF copies of the slides I presented. If you have any questions, feel free to ask in the comments here or reach out to me. Look forward to presenting at more events later this year as opportunities arise.
Getting Up to Speed with Microsoft Graph Development
After a few years off from community speaking engagements I’m excited to return to speak at M365 Twin Cities (formerly SharePoint Saturday Twin Cities, now with expanded scope and topics) on Jan 21, 2023. I’ve spoken at this conference twice before and have been very impressed with the level of organization, attendee engagement, and content all-up. I’ll be presenting the following 2 sessions. Registration is still open. If you are in the area, please sign up and look forward to seeing you there.
Title: Getting Up to Speed with Microsoft Graph Development
Description: “I hear that I need to use Microsoft Graph for developing against Microsoft 365 but I have no clue where to start.” “I want to grant access to company data without throwing in the entire kitchen sink.” Fear not fellow developers and admins. This session we will ramp you up to a 200 level knowledge on the pertinent parts of Microsoft Graph including endpoints available, syntax, authentication flows, and more. We will also cover useful examples of what can be accomplished using these APIs. Prior experience with Microsoft Graph is not required but can be helpful.
Title: How to Use Power Automate and Microsoft Graph in Daily Work
Description: Do you need to automate parts of your daily work routine? What Microsoft Cloud data is available through Microsoft Graph for automating? In this session we’ll walk through multiple real world examples of using Power Automate for daily tasks such as assigning round robin tasks to team members, sending weekly reminders, processing survey results, and more. Prior experience with Power Automate is useful but not required. Target audience is open to all (productivity workers, developers, admins, etc.)
Do you ever want to test a few lines of code, but have to write dozens of lines of support code (i.e. “boilerplate” or “basic plumbing” code)?
Microsoft Graph has a number of offerings such as quick starts to let you pick a supported code language, download a sample application, and run the project within a few minutes, but this can still take 5-30 mins depending on your level of familiarity.
Separately, there is Microsoft Graph Explorer or the Microsoft Graph Postman collection to quickly execute a query against Microsoft Graph (seconds to minutes usually), but these only execute HTTP REST endpoints and not using SDKs (which I prefer).
I’ve used 3rd party tools such as LINQPad or websites like .Net Fiddle to quickly prototype and execute Microsoft Graph SDK code but these are often disconnected experiences from where I typically develop which is Visual Studio Code.
.Net Interactive and Polyglot Notebooks
Enter .Net Interactive. .Net Interactive builds upon the Jupyter ecosystem (notebooks, kernels, server, etc.) to allow programming in a notebook fashion (executable code alongside text) but with support for multiple languages (C#, F#, JavaScript, PowerShell, SQL, and more). With this added support for multiple languages, the Visual Studio Code extension has been recently renamed to Polyglot Notebooks (previously called .Net Interactive Notebooks), but the base engine itself is still called .Net Interactive.
At a base level, Polyglot Notebooks allow you to write snippets of executable code in multiple languages alongside markdown text blocks. This is great for writing tutorials, sharing a sample of code with someone with explanation (beyond simple comments in the code), or designing a multi-step process of code blocks.
.Net Interactive is also extensible by allowing developers to create custom kernel extensions, magic commands, or script-based extensions.
Microsoft Graph extension for .Net Interactive
During a recent company hackathon event, myself, Jason Johnston, Jon Sequeira, and Diego Colombo built an initial prototype of a Microsoft Graph extension for .Net Interactive. The extension implements a magic command for #!microsoftgraph that can create and authenticate a GraphServiceClient and then binds it to a variable that can then be used in code blocks. The magic command accepts input parameters to control authentication flow, Azure AD application / tenant, Microsoft Graph API version, and more. The current repository includes support for C# (.Net) but we’re also exploring JavaScript and PowerShell in the future.
Prerequisites
There are a few prerequisites that you will need install
After above requirements are met, you can get started by following the instructions in the GitHub repo README or the demo notebook.
Let’s take a look at a few samples.
Create a polyglot notebook
To create a new polyglot notebook, open the Command Palette(Ctrl+Shift+P) on Windows or (Cmd+Shift+P) on MacOS, and select Polyglot Notebook: Create new blank notebook. You can also create a new notebook with Ctrl+Shift+Alt+N key combination on Windows.
Build the NuGet package
After forking the repository, navigate to the source directory and run the following command (or execute in a PowerShell code block inside the notebook) to generate a NuGet package which we will then import in the next steps.
After the NuGet package has been built, run the following commands (be sure to replace <REPLACE_WITH_WORKING_DIRECTORY> with the actual directory location) in a C# script block in the notebook to import the NuGet package.
Executing the #!microsoftgraph magic command with -h or –help will display the syntax and parameters available for input. Note that options are available with full name (two dashes “–“) or aliases (one dash “-“).
#!microsoftgraph -h
Create client
The following creates an instance of a GraphServiceClient with variable name “deviceCodeClient” using the device code authentication flow. Be sure to replace the input parameters for “YOUR_TENANT_ID” and “YOUR_CLIENT_ID”.
#!microsoftgraph -t "YOUR_TENANT_ID" -c "YOUR_CLIENT_ID" -a DeviceCode -n deviceCodeClient
Since we used -n to name the GraphServiceClient instance that is created, we can now use that variable going forward to make requests.
Make requests
Now you can execute Microsoft Graph .Net SDK code using the deviceCodeClient GraphServiceClient just created. We will be prompted to complete the device code authentication flow at this time. Follow the prompt and provide the device code provided.
var me = await deviceCodeClient.Me.GetAsync();
Console.WriteLine($"Me: {me.DisplayName}, {me.UserPrincipalName}");
Live demo
Recently Jason Johnston and I joined the M365 platform community call to give an overview and demo of the Microsoft Graph extension for .Net Interactive. If you want to skip to just the demo, jump to 8:28 timestamp in the video to see things in action.
Conclusion
As you can see, the Microsoft Graph extension for .Net Interactive offers a way to write code and text side by side. There are many scenarios that can benefit from this such as workshop tutorials, exploring the SDKs, prototyping solutions, and more. We welcome your input on feature requests, contributions, raising bugs, etc. Please submit issues or pull requests to the GitHub repository and we will review. Thanks and enjoy!
When I joined the Microsoft Graph team I set up recurring 1:1 meetings with each of my teammates and a number of people from other teams within our group. As luck would have it those meetings defaulted to have an end date ~1 year from when the series was created.
As you might guess, I forgot to extend some of those meetings and then after they reached their end date I had to go through my calendar to find which ones were impacted and extend them.
<Update 2023-02-02>I confirmed with the PM for this endpoint that the Recurrence property does not support filtering at this time. As such you will need to filter client-side through your own means.</Update>
The below query is intended to find all recurring meetings on your Exchange Online calendar. It is not a complete solution as I haven’t figured out the exact syntax for recurrence property with an end date in the past. Hopefully someone finds this useful and if you have enhancements to help with filtering please feel free to share in the comments.
Note that type = ‘seriesMaster’ will only find the series and not individual meeting instances which may have exceptions from the original recurrence pattern.
I’ve always enjoyed “Show and Tell Fridays”, “Brown bag sessions” (i.e. bring your lunch and a presenter shares about a topic), and hackathons to see what cool things my peers are working on. Not only do I get to see / hear interesting projects and solutions they are building, it also sparks creativity in me to work on my own projects.
During our September 2022 company-wide hackathon I had the opportunity to collaborate with folks from multiple areas of Microsoft (Teams, Outlook, .Net Interactive, M365 Profile, and more) on interesting projects. What was really interesting to me is that 2 of these projects started via tweets on Twitter. A random message from myself was picked up by one engineering team for 1 project and a thread from a peer about “wouldn’t it be cool if…” started another project.
Ultimately, I highly recommend that you take the time to share early and share often your ideas, interests, side projects, and more. You never know how that may lead you and your peers to build the next innovative product / feature / etc.
For those interested, here is a link to one of the hackathon projects I worked on for a “Microsoft Graph extension for .Net Interactive”. For those unfamiliar, .Net Interactive Notebooks allow you to mix text (Markdown) and runnable code snippets (multiple languages supported) in a notebook style format. This custom extension allows authenticating to Microsoft Graph via 3 different authentication flows (possibly more to come) and run Microsoft Graph SDK queries easily.
I’ll be sharing more about this on my blog, M365 platform community call, and a few other places as it continues to develop. For now follow / star / fork / etc. the GitHub repo for more updates.
Last week, a number of my fellow teammates (Darrel Miller, Fabian Williams, Sebastian Levert, Beth Pan, Vincent Biret, and Walkdek Mastykarz) from the Microsoft Graph team joined the Hello World show for a special episode. We covered a number of great topics like getting started with Microsoft Graph, using Microsoft Graph Toolkit, and learning about SDK support. Check out the recording or jump to specific segments of the show!