c# - 尝试删除 Azure Functions 中的 blob,但缺少 DeleteIfExists 方法
问题描述
我使用 BlobTrigger 模板创建了一个带有 Blob 触发器的新 C# Azure 函数。然后我将 blob 触发器绑定的类型更改为 CloudBlockBlob。接下来我尝试添加一行来删除 blob。结果是函数编译错误:
[Error] run.csx(8,12): error CS1061: 'CloudBlockBlob' does not contain a definition for 'DeleteIfExists' and no extension method 'DeleteIfExists' accepting a first argument of type 'CloudBlockBlob' could be found (are you missing a using directive or an assembly reference?)
我错过了什么?根据文档 CloudBlockBlob 应该有一个名为 DeleteIfExists 的方法。
这是我的整个功能:
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
public static void Run(CloudBlockBlob myBlob, string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Properties.Length} Bytes");
myBlob.DeleteIfExists();
}
解决方案
如果您使用的是 Functions v2,那么您可能正在使用 .NET Core 或 .NET Standard,它们似乎只支持异步方法。改为使用await myblob.DeleteIfExistsAsync()
。
推荐阅读
- asp.net-core - 将 NSwag 与 .NET 5 一起使用时如何显示完整的招摇界面?
- node.js - Forge 内部发生未处理的拒绝:错误:在 devDependencies 中找不到任何电子包
- node.js - Aws Image rekognition that Detecting inappropriate images with node js
- java - 如何在 Java 中对构建器模式中的诱惑步骤进行分组?
- python - 如何使用 Python 在不同文件夹中移动相同数量的文件
- safari - Flutter Web -Wakelock 在 iOS Safari 上不起作用
- python - 从打开函数访问文件而不调用它
- javascript - react 如何知道这个组件将被卸载?
- excel - 访问 Excel TextToColumns 的 Word 宏
- python - 在python中将BMP转换为WSQ格式