I had a working http triggered Azure function a year ago. Not anymore. I created new azure function (runtime ~4) and now I can not compile it in Azure editor. It says "[Error] run.csx(2,1): error CS0006: Metadata file 'Microsoft.WindowsAzure.Storage' could not be found". It is simply geting list of files from my Azure BLOB storage. I am loosing my mind, I don't know what to cofigure, or how to change my code. Is Microsoft.WindowsAzure.Storage no loner supported? I was wondering about lowering my runtime version, but it is grey-out (I can not change it). I read this How to replace Microsoft.WindowsAzure.Storage with Microsoft.Azure.Storage.Blob But I trying #r "Azure.Storage.Blobs" have the same result
#r "Newtonsoft.Json"
#r "Microsoft.WindowsAzure.Storage"
using System;
using System.Configuration;
using System.Net;
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string connectionString = "MY_CONNECTION_STRING";
var storageAccount = CloudStorageAccount.Parse(connectionString);
CloudBlobClient client = storageAccount.CreateCloudBlobClient();
string rootDirectoryName = name.Replace(" ", "");
CloudBlobContainer container = client.GetContainerReference("storage");
CloudBlobDirectory folder = container.GetDirectoryReference(rootDirectoryName);
CloudBlobDirectory modelFolder = folder.GetDirectoryReference("giftpics");
BlobResultSegment segment = await modelFolder.ListBlobsSegmentedAsync(null);
List<IListBlobItem> list = new List<IListBlobItem>();
list.AddRange(segment.Results);
while (segment.ContinuationToken != null)
{
segment = await container.ListBlobsSegmentedAsync(segment.ContinuationToken);
list.AddRange(segment.Results);
}
List<string> blobNames = list.OfType<CloudBlockBlob>().Select(b => b.Name.Replace(rootDirectoryName, "").Replace("giftpics", "").Replace("/", "")).ToList();
string contents = JsonConvert.SerializeObject(blobNames);
return new OkObjectResult(contents);
}
thanks for your answer but I created new Azure Function APP with .net 3.1 which solved my issue
I struggled on this too.....I think I might have found a solution for it, not sure. But try this, it might work:
Try changing your runtime to ~3. This worked for me, but I am not a developer so I have no idea what any ramifications this might have.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.