This proof of concept demonstrates how to store an Excel file to Onedrive/Sharepoint and open the file with Excel Online using Dotnet Framework 4.61.
This application use the Microsoft Graph API to store files in a Sharepoint Site. Documentation for the Microsoft Graph SDK.
The web application authenticates to Microsoft using a Service Principal.
To create a service princial go to the Azure Portal and sign in as a Global Administrator
- Go to Microsoft Entra Id
- Click Enterprise Applications
- Click New application
- Click Create your own application
- Give the aplication a name and select Register an application to integrate with Microsoft Entra ID (App you're developing), click Next
- Select Accounts in this organizational directory only (
Your tenanat name
only - Single tenant) and click Register
- Search for your application in Entra Id | App Registrations
- Select Api Permissions and click Add a permission
- Select Microsoft Graph
- Select Application Permission
- Type Files in the serachbar and select
Files.ReadWrite.All
and click Add Permission - Click Grant admin consent for
Your tenanat name
- Search for your application in Entra Id | App Registrations
- Select Certificates & secrets and click New Client Secret
- Give your secret a name and expire date and click Add
Important
Copy and store the client secret value in a secure location. This is the only time you are allowed to do this
The application use the Azure.Identity nuget package, and the code expects the following environment variables
Variable name | Value |
---|---|
AZURE_CLIENT_ID |
ID of a Microsoft Entra application |
AZURE_CLIENT_SECRET |
The application's client secrets |
AZURE_TENANT_ID |
ID of the application's Microsoft Entra tenant |