用门户(CSX)编写的Azure函数,带有外部引用的Nuget软件包不起作用

发布于 2025-02-07 13:21:42 字数 1214 浏览 2 评论 0原文

我正在尝试制作一个非常简单的斑点功能,我似乎无法完成这项工作。 有人知道这里有什么问题吗?

代码:

#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);
}

function.proj

<PropertyGroup>

    <TargetFramework>.NETCoreApp,Version=v3.1</TargetFramework>

</PropertyGroup>

<ItemGroup>

     <PackReference Include="SixLabors.ImageSharp" Version="2.1.2"/>

</ItemGroup>

of(似乎没关系):

<PropertyGroup>

    <TargetFramework>netstandard2.1</TargetFramework>

</PropertyGroup>

<ItemGroup>

     <PackReference Include="SixLabors.ImageSharp" Version="2.1.2"/>

</ItemGroup>

错误: “错误] run.csx(2,1):错误cs0006:元数据文件'sixlabors.imagesharp'找不到'无法找到”。

I am trying to make a very simple blobtriggered function, I cannot seem to make this work.
Anyone any idea what is wrong here?

Code:

#r "SixLabors.ImageSharp"
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

 

public static void Run(Stream myBlob, string name, Stream imageSmall, ILogger log)
{
    log.LogInformation(
quot;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);
}

Function.proj

<PropertyGroup>

    <TargetFramework>.NETCoreApp,Version=v3.1</TargetFramework>

</PropertyGroup>

<ItemGroup>

     <PackReference Include="SixLabors.ImageSharp" Version="2.1.2"/>

</ItemGroup>

Of (doesn’t seem to matter):

<PropertyGroup>

    <TargetFramework>netstandard2.1</TargetFramework>

</PropertyGroup>

<ItemGroup>

     <PackReference Include="SixLabors.ImageSharp" Version="2.1.2"/>

</ItemGroup>

Error:
“Error] run.csx(2,1): error CS0006: Metadata file 'SixLabors.ImageSharp' could not be found”.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤云独去闲 2025-02-14 13:21:42

谢谢 @ Mohitganorkar-Mt 指出解决方案,将其发布为对其他社区成员的好处的答案。

错误:“错误] run.csx(2,1):错误CS0006:元数据文件
找不到'sixlabors.imagesharp'。

对于上述内容,我们尝试使用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>

有关更多信息,请参阅此博客| 创建一个使用c# 触发的azure函数,由 @ jay jay krishna reddy em>。

Thanks @MohitGanorkar-Mt for point out the solution ,posting it as answer to benefit for other community members for the similar issue.

Error: “Error] run.csx(2,1): error CS0006: Metadata file
'SixLabors.ImageSharp' could not be found”.

For the above We have tried to create an Azure function using blob trigger and it works fine as well from our end .

The function.csproj you have item group with packreference instead of that we have to use as shown below:

<PropertyGroup>

    <TargetFramework>.NETCoreApp,Version=v3.1</TargetFramework>

</PropertyGroup>

<ItemGroup>

     <PackageReference Include="SixLabors.ImageSharp" Version="2.1.2"/>

</ItemGroup>

similarly with 2.1 as well

<PropertyGroup>

    <TargetFramework>netstandard2.1</TargetFramework>

</PropertyGroup>

<ItemGroup>

     <PackageReference Include="SixLabors.ImageSharp" Version="2.1.2"/>

</ItemGroup>

enter image description here

For more information please refer this BLOG|Create an Azure Function Triggered By Blob Storage Using C# by @Jay Krishna Reddy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文