How To: Integrating Microsoft Graph API in Your ASP.NET MVC

Problem You want to develop web application that use data from Microsoft Graph especially data from Office 365. You already follow the tutorial from Microsoft Docs, but you need to find a better and quick integration with Visual Studio 2019 by minimizing the codes development medianet_width = "600"; medianet_height = "250"; medianet_crid = "858385152"; medianet_versionId = "3111299"; Before we start We need to make sure you have this before we get started Office 365 subscription. If you need the sandbox environment my recommendation is to register to Microsoft 365 Developer Program Visual Studio 2019 Community or Better Azure Active Directory that already activated by default when you have Office 365 Subscription This tutorial assumes that you use your own Azure AD. Let's Get Started Step 1 – Login with your Account in Visual Studio Open your Visual Studio Select Continue without Code Click File – Account Settings Click Add an Account Add you Office 365 Account that has an access to the Azure AD Step 2 – Creating a Visual Studio Project File, New, Project (Ctrl + Shift + N) Choose ASP.NET Web Application Create your project, I recommend you follow this naming Please follow the animation below Step 3 – Add Additional API Permission in Azure AD Visit the azure AD portal by login with Your Azure AD owner account. In this case, I use my Office 365 developer program account Configure the API permission by selecting Azure Active Directory, Your Application, and API Permission. Please follow this animation On this example, we want to read the Calendar and Basic Profile of Office 365 Account Step 4 – Adding Microsoft Graph Codes Functionality Please add Graph client library for MVC, by Right Click of Package and select Nuget Package Manager, click browse and search for Microsoft Graph We are ready to go here are the brief what we will do in this step: (1) changing the codes from Azure AD endpoint ( to Microsoft 365 endpoint (; (2) creating codes helpers to consume the Graph API We will discuss the codes in the video tutorial (please see below) Step 5 – Creating Controller, View, and Model for Calendar function This is routine step to create controller, view, and model. This step is described in video tutorial (please see below) You can download the codes in the OneDrive medianet_width = "600"; medianet_height = "250"; medianet_crid = "858385152"; medianet_versionId = "3111299";

Five Things that you do in Visual Studio 2019 to Improve your codes

Building codes is one of the top missions of any software developer in the world. Improving our codes to improve code readability, maintenance, and performance. Today, we will discuss five things that you can do to improve your code's quality by using Visual Studio. Let's get started   // #1 Code analyzers This is a good feature to understand your codes better. This technique uses FX cop to analyze your codes. You will have a recommendation, code-tips, and comments about your codes based on common coding practices #2 Code Cleanup You can run code cleanup to clean and to eliminate useless codes. You can configure the clean up just like a disk cleanup in windows. Less is more. #3 Live share Need a code monkey or support from the expert pals. You can get in touch with them by using Live Share. Live share is a code-sharing feature by using live streaming protocol. You can collaborate with more than five persons to build codes on the same pages. The editing process will be live just like document editing in Office 365. Just give them a link, and you are ready to go #4 Refactoring Refactoring comes with quick action features that allow you to improve the codes through a contextual recommendation. Just hover your codes and choose quick actions and refactoring, you will amaze how refactor process can help you to compose efficient codes. #5 Say no to Copy and Paste Codes Visual Studio has a code clones features to help you identify the repetitive codes. You can run the code clones, and the Visual Studio will help you identify the replicated codes and how to manage it. Pro Tips: Run the code clones, and then refactoring will make you. That's it five tips to manage your codes easily by using Visual Studio 2019, have other tips to improve your codes? Just put in the comment, and I will add it to the list. Enjoy your weekend //

Topics Highlights

Translate It

About @ridife

This blog will be dedicated to integrate a knowledge between academic and industry need in Application Lifecycle Management (ALM), ICT tips, and Software Engineering Research. Enjoy this blog and let's get in touch in any social media.


Month List