不知何故,我不能在使用csx的Azure函数v2中使用Microsoft.Azure.Storage.blob包。
在extension.proj中,我有以下内容:
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.0" />在csx文件中,我有:
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Blob;我犯了一个错误:
run.csx(7,23): error CS0234: The type or namespace name 'Storage' does not exist in the namespace
'Microsoft.Azure' (are you missing an assembly reference?)完整代码在GitHub上:https://github.com/ptrstpp950/cognitive-service-azure-function
发布于 2019-10-16 09:49:59
1.是否确定正在使用 extension.proj ?
从你的代码中我知道你在门户上写东西。因此您应该在门户上创建function.proj而不是extension.proj。
2.我看到你在.proj文件中写 <PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.0" /> 。因此,您应该使用 #r "Microsoft.WindowsAzure.Storage" using Microsoft.WindowsAzure.Storage而不是
下面是我的function.proj的代码,事情在我这边运行得很好。有关更多详细信息,请查看此Offical doc。(所有解决方案都基于您正在使用的function 2.x。如果您使用的是function 1.x。这是不一样的。)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.0" />
</ItemGroup>
</Project>

我的.crx文件代码:
#r "Newtonsoft.Json"
#r "Microsoft.WindowsAzure.Storage"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using Microsoft.Azure.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;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}发布于 2019-10-15 22:29:14
您应该在使用该包之前导入它:
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.Extensions.Logging;https://stackoverflow.com/questions/58391122
复制相似问题