我正在创建一个 Azure 函数,当图像上传或添加到特定的 Azure 存储时会触发该函数,它会执行以下操作:
1.) 调整图像大小
2.) 将图像放入正确的目录(使用输出绑定)
3.) 删除处理后添加到 Azure 存储的原始 blob 图像。
我已完成该过程中的步骤 1 和 2,但我发现有关删除 Blob 或公开 Azure 存储方法的 API 的文档很少甚至没有。 (使用C#)
这是示例代码:
#r "System.Drawing"
using System;
using ImageResizer;
using System.Drawing;
using System.Drawing.Imaging;
public static void Run(Stream inputImage, string imageName, Stream resizedImage, TraceWriter log)
{
// Log the file name and size
log.Info($"C# Blob trigger function Processed blob\n Name:{imageName} \n Size: {inputImage.Length} Bytes");
// Manipulate the image
var settings = new ImageResizer.ResizeSettings
{
MaxWidth = 400,
Format = "png"
};
ImageResizer.ImageBuilder.Current.Build(inputImage, resizedImage, settings);
// Delete the Raw Original Image Step
}
要删除 blob,您需要
var container = blobClient.GetContainerReference(containerName);
var blockBlob = container.GetBlockBlobReference(fileName);
return blockBlob.DeleteIfExists();
请确保在尝试此操作之前关闭所有流,以便不再使用该图像。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)