#How to convert ASP.NET for Microsoft Graph API to an open public API?

Jorziño Barradas 20 Reputation points
2024-06-28T13:08:45.0433333+00:00

Hello,

I have followed the instructions for creating an application that can pull data using the Microsoft Graph API:

https://learn.microsoft.com/en-us/entra/identity-platform/tutorial-web-app-dotnet-sign-in-users?tabs=visual-studio#implement-authentication-and-acquire-tokens

Currently I can only get the data by running the VS project. I want to convert/deploy this project as a GET web API so that I can pull data using the web link and automate the query process.

Can someone please help me this request?

Any help will be much appreciated.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,626 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,329 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 67,016 Reputation points
    2024-06-30T18:18:08.2266667+00:00

    You need a hosting environment. Then you deploy to the environment.

    https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/?view=aspnetcore-8.0

    0 comments No comments

  2. Tiny Wang-MSFT 2,731 Reputation points Microsoft Vendor
    2024-07-01T05:50:03.2366667+00:00

    Hi Jorziño, Currently I can only get the data by running the VS project which means you are now able to pull data via Graph API by calling request like https://localhost:port/get-data-endpoint. This link can only be used in your own machine. To make it to be public and open, we require a server and application host, deploy the app to the server, then make the server and the port we select to be public, it might be complex for you. So I'm afraid that using the out-of-box cloud service - Azure web app is a good option for you. It has free pricing tier to host a web application, but we need to sign up for free and create subscription in advance.

    Then we can try to publish the application to Azure via Visual Studio. My demo is using an .Net 6 MVC application. Just right click on the project name and click "Publish",

    User's image

    Then choose Azure as the publish target, and then choose Azure App Service(windows).User's image

    User's image

    Next you will need to sign in with the account you sign up just now, and let's create a new resource group(used to put Azure services worked like a folder) and create a new service plan (define where you host your app, and how much CPU/Memory you want to use, let's choose the free pricing tier for test purpose).

    User's image

    After we create the web app instance along with the resource group it placed and the service plan it used, we choose this instance and click finish. Then we will close the configuration Dialog and then click the Publish button to publish the application to Azure. After the progress is completed, it will automatically open your browser to visit a website like webappname.azurewebsites.net and you can visit this site in any client.

    Here's the tutorial for using VS to publish web app to Azure, you can follow this tutorial as well.

    ==========================================

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Tiny

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.