为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

C#
跃然一笑 2022-10-15 14:44:06
我使用 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 回答

?
精慕HU

TA贡献1845条经验 获得超8个赞

如果您使用的是 Functions v2,那么您可能正在使用 .NET Core 或 .NET Standard,它们似乎只支持异步方法。改为使用await myblob.DeleteIfExistsAsync()



查看完整回答
反对 回复 2022-10-15
  • 1 回答
  • 0 关注
  • 109 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号