尝试删除Azure Functions中的Blob但缺少DeleteIfExists方法

时间:2019-03-07 12:57:22

标签: c# azure azure-functions azure-storage-blobs

我使用带有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();
}

1 个答案:

答案 0 :(得分:0)

如果使用的是Function v2,则可能使用的是.NET Core或.NET Standard,它们似乎仅支持异步方法。请改用await myblob.DeleteIfExistsAsync()