【发布时间】:2019-10-20 23:33:01
【问题描述】:
我正在尝试使用 Azure 函数(HTTP 触发器)在 azure blob 存储中上传 excel 文件。我附上了我的代码。它无法正常工作。
我收到"Cannot implicitly convert type 'System.Threading.Tasks.Task<System.Collections.Generic.List<FileUpload1.Function1.FileDetails>>' to 'FileUpload1.Function1.FileDetails' FileUpload" 之类的错误
请帮帮我。
[FunctionName("Function1")]
public static FileDetails Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req,
ILogger log)
{
if (!req.Content.IsMimeMultipartContent("form-data"))
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
var multipartStreamProvider = new AzureBlobStorageMultipartProvider(BlobHelper.GetWebApiContainer());
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("configuratorstorage1");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("excelfiles");
//var count = container.ListBlobs().Count(); return
return req.Content.ReadAsMultipartAsync(multipartStreamProvider).ContinueWith(t =>
{
if (t.IsFaulted)
{
throw t.Exception;
}
AzureBlobStorageMultipartProvider provider = t.Result;
return provider.Files;
});
我希望我必须使用 azure 函数 HTTP 触发器在 azure blob 存储中上传 excel 文件。
【问题讨论】:
-
您是否尝试过找到任何示例? (有一吨)social.technet.microsoft.com/wiki/contents/articles/…
标签: c# azure azure-functions azure-cosmosdb azure-blob-storage