Вы можете поместить файл в тело запроса запроса следующим образом, а затем загрузить его в azure хранилище BLOB-объектов.
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Microsoft.WindowsAzure.Storage;
namespace FunctionApp5
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
//Here is the keycode.
//Connect to the Storage Account.
var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=bowmanimagestorage02;AccountKey=xxxxxxxfile.core.windows.net/");
var myClient = storageAccount.CreateCloudBlobClient();
//Here is the container name on portal.
var container = myClient.GetContainerReference("test");
//Here is the name you want to save as.
var blockBlob = container.GetBlockBlobReference("something.txt");
//Put the stream in this place.
await blockBlob.UploadFromStreamAsync(req.Body);
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
}
Конечно, вы также можете передать поток данных, Код ключа тот же.