我正在尝试从 Azure 函数访问 Blob 存储中的内容。我有以下内容:
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
public static async Task<HttpResponseMessage> Run(HttpRequest req, ILogger log)
{
string path = req.Query["path"];
string storageConnectionString = "...";
CloudStorageAccount blobAccount = CloudStorageAccount.Parse(storageConnectionString);
CloudBlobClient blobClient = blobAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("content");
CloudBlockBlob cloudBlockBlob = blobContainer.GetBlockBlobReference(path);*
return new HttpResponseMessage(HttpStatusCode.OK) {
Content = /* to do - content of blob */
};
}
但是,我很难告诉函数识别 Microsoft.WindowsAzure.Storage 命名空间:
2019-11-07T09:59:57.729 [Error] run.csx(7,17): error CS0234: The type or namespace name 'WindowsAzure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
我觉得我对 Azure Functions 的理解缺少一些重要的东西,因为从 Azure 函数中引入命名空间/包以与 Azure 一起工作不应该是一个挑战。
非常感谢!