我有一个带有一个输入和两个输出的天蓝色功能应用程序。在这种情况下,每当图像上传到容器:原件时,将触发功能应用程序,这将生成两个缩略图图像。
我使用VS2017开发了以下功能应用程序并部署到Azure门户。
码:
using ImageResizer;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using System;
using System.Collections.Generic;
using System.IO;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run(
[BlobTrigger("originals/{name}", Connection = "xxxxxxx")]Stream image,
[Blob("thumbs/s-{name}", FileAccess.ReadWrite, Connection = "xxxxxxx")]Stream imageSmall,
[Blob("thumbs/m-{name}", FileAccess.ReadWrite, Connection = "xxxxxxx")]Stream imageMedium,
TraceWriter log)
{
var imageBuilder = ImageResizer.ImageBuilder.Current;
var size = imageDimensionsTable[ImageSize.Small];
imageBuilder.Build(
image, imageSmall,
new ResizeSettings(size.Item1, size.Item2, FitMode.Max, null), false);
image.Position = 0;
size = imageDimensionsTable[ImageSize.Medium];
imageBuilder.Build(
image, imageMedium,
new ResizeSettings(size.Item1, size.Item2, FitMode.Max, null), false);
}
public enum ImageSize
{
ExtraSmall, Small, Medium
}
private static Dictionary<ImageSize, Tuple<int, int>> imageDimensionsTable = new Dictionary<ImageSize, Tuple<int, int>>()
{
{ ImageSize.ExtraSmall, Tuple.Create(320, 200) },
{ ImageSize.Small, Tuple.Create(640, 400) },
{ ImageSize.Medium, Tuple.Create(800, 600) }
};
}
}
在验证它时,我发现它根据需要生成两个不同的图像,但我看到其中一个文件已损坏。
CorrectImage:
图像损坏:
我对多个图像进行了验证,但看到了同样的问题。中等大小配置的图像总是被破坏。
对上述代码的任何修正都非常有用。
任何人都可以帮我解决这个问题吗?
你能否检查一下其他功能应用程序是否已经处于运行状态。简而言之,我想说检查您在此过程中开发的所有功能应用程序,即监视blob存储容器。我怀疑其他一些功能应用程序正在被触发并导致此问题。请停止所有功能应用程序,并仅运行所需的功能应用程序以查看它是否可以解决您的问题。如果您需要任何进一步的帮助,请告诉我。