Feature: OneDrive Provider (ManagedCode.Storage.OneDrive)
Purpose
Expose OneDrive / Microsoft Graph as IStorage so .NET apps can store files in a drive/folder via Graph using the same provider-agnostic upload/download/list/delete API as other backends:
- upload/download/list/delete through a consistent API
- keep auth concerns in the hosting app (you provide a
GraphServiceClient), while still allowing a swap point for tests
Main Flows
flowchart LR
App --> OD[OneDriveStorage : IOneDriveStorage]
OD --> Client[IOneDriveClient]
Client --> Graph[Microsoft Graph]
Components
- Storage:
- Client wrapper:
- Options / DI:
DI Wiring
dotnet add package ManagedCode.Storage.OneDrive
dotnet add package Azure.Identity
using Azure.Identity;
using ManagedCode.Storage.OneDrive.Extensions;
using Microsoft.Graph;
var credential = new ClientSecretCredential(
tenantId: configuration["OneDrive:TenantId"]!,
clientId: configuration["OneDrive:ClientId"]!,
clientSecret: configuration["OneDrive:ClientSecret"]!);
var graphClient = new GraphServiceClient(credential, new[] { "https://graph.microsoft.com/.default" });
builder.Services.AddOneDriveStorageAsDefault(options =>
{
options.GraphClient = graphClient;
options.DriveId = "me";
options.RootPath = "app-data";
});
Current Behavior
- You can provide either:
OneDriveStorageOptions.Client(customIOneDriveClientswap point, mainly for tests), orOneDriveStorageOptions.GraphClient(official SDK client)
- Container deletion is not supported (drives/folders are account-managed).
Tests
- HTTP/SDK-level fake:
- Storage behaviour via fake client:
- DI + provider plumbing:
Configuration Notes
See docs/Development/credentials.md and README.md for step-by-step instructions on Entra ID app registration and Graph auth.