I am trying to upload excel file in azure blob storage with Azure functions (HTTP Trigger ). I attached my code. It is not working properly.
I am getting errors like "Cannot implicitly convert type 'System.Threading.Tasks.Task<System.Collections.Generic.List<FileUpload1.Function1.FileDetails>>' to 'FileUpload1.Function1.FileDetails' FileUpload"
Please help me out from this.
[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;
});
I am expecting that I have to upload excel file in azure blob storage with azure functions HTTP trigger.