c# - 尝试删除 Azure Functions 中的 blob,但缺少 DeleteIfExists 方法

标签 c# azure azure-functions azure-blob-storage

我使用 BlobTrigger 模板创建了一个带有 Blob 触发器的新 C# Azure 函数。然后,我更改了绑定(bind)到 CloudBlockBlob 的 Blob 触发器的类型。接下来我尝试添加一行来删除该 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()

关于c# - 尝试删除 Azure Functions 中的 blob,但缺少 DeleteIfExists 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55044361/

相关文章:

c# - "System.IO.IOException: The process cannot access the file ' C :\Test\test. 文本 ' because it is being used by another process"

c# - 如何读取 ASP.NET 原始 URL 的查询字符串参数?

c# - 如何使用性能计数器获取进程正在运行的线程数?

azure - 选择-AzureRm订阅 : Please provide a valid tenant or a valid subscription

python - Azure 函数 python 命名参数没有值

javascript - Nodejs HTTP 重试模式

c# - 为什么win32异常没有被c#异常处理机制捕获

azure - 如何使用多个keyvault并使用循环?地形

python - 如何获取当前上下文(登录实体)objectId

azure - 从 Azure 门户中的 Azure Function 检索源代码文件