Saving a file in OneDrive from Azure Functions

Viewed 158

What's the simplest way for an Azure Functions to save a file into OneDrive? How does authentication work from a deployed Azure Function? To make this discussion simpler, we have a string var content = "This is the file content" which needs to be saved as sample.txt file.

What if OneDrive folder is shared with an URL (real shared OneDrive link, will be removed - https://1drv.ms/f/s!Ak7ywxppmRtB8uRKhvT1FLmNBwXNwQ) and no authentication is required?

1 Answers

I'd recommend taking a look at the Microsoft Graph APIs for managing files stored in OneDrive.

They have great C# examples using the Microsoft.Graph NuGet package. You will need to implement a mechanism of authentication however and I don't think there is a way around this. For the Graph, I'd recommend looking at these implementations for getting authenticated for a user.

Once you've authenticated in your Function app, you should be able to get to where you need to be using the Graph APIs for OneDrive available.

Related