使用外部引用的 nuget 包在 Portal (CSX) 中编写的 Azure Functions 不起作用

标签 azure azure-functions

我正在尝试创建一个非常简单的 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 grouppackreference,而不是我们必须使用的,如下所示:

<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>

enter image description here

欲了解更多信息,请参阅此博客| 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/

相关文章:

java - 通过 Java struts Web 应用程序在 Azure AD 中进行 SAML 身份验证

时间:2019-03-17 标签:c#AzureFunctions分离html和css

azure-functions - Azure 函数无法在 Azure 门户中下载 PowerShell Core 的托管依赖项

c# - 使用 Azure 门户将 .nupkg 文件上传到我的 Azure 函数

c# - 将位图对象上传到 Azure Blob 存储

c# - 有没有办法知道当前网络角色包含多少个实例?

azure - 在 Azure Powershell 函数中使用 Azure CLI

azure - 如何在 Azure 资源管理器模板中为 Azure 函数配置应用服务托管证书?

azure - 仅允许从前端到 ADF 前门的流量

c# - 是否可以使用 Azure Functions V2 输出 Message/BrokeredMessage?