我正在尝试创建一个非常简单的 blobtriggered 函数,但我似乎无法使其工作。 有人知道这里出了什么问题吗?
代码:
#r "SixLabors.ImageSharp"
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
public static void Run(Stream myBlob, string name, Stream imageSmall, ILogger log)
{
log.LogInformation($"C# Bolob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
using var image = Image.Load(myBlob);
int width = image.Width / 2;
int height = image.Height / 2;
image.Mutate(x => x.Resize(width, height));
image.Save(imageSmall);
}
函数.proj
<PropertyGroup>
<TargetFramework>.NETCoreApp,Version=v3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackReference Include="SixLabors.ImageSharp" Version="2.1.2"/>
</ItemGroup>
(似乎并不重要):
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackReference Include="SixLabors.ImageSharp" Version="2.1.2"/>
</ItemGroup>
错误: “错误] run.csx(2,1):错误 CS0006:找不到元数据文件“SixLabors.ImageSharp””。
最佳答案
感谢@MohitGanorkar-Mt指出解决方案,将其作为答案发布,以造福其他社区成员解决类似问题。
Error: “Error] run.csx(2,1): error CS0006: Metadata file 'SixLabors.ImageSharp' could not be found”.
对于上述内容,我们尝试使用 blob 触发器创建一个 Azure 函数,并且从我们的角度来看它也运行良好。
您的function.csproj
具有item group
和packreference
,而不是我们必须使用的,如下所示:
<PropertyGroup>
<TargetFramework>.NETCoreApp,Version=v3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.2"/>
</ItemGroup>
与 2.1 类似
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.2"/>
</ItemGroup>
欲了解更多信息,请参阅此博客| Create an Azure Function Triggered By Blob Storage Using C#作者:@Jay Krishna Reddy。
关于使用外部引用的 nuget 包在 Portal (CSX) 中编写的 Azure Functions 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72629854/