【问题标题】:File Share Deletion (Azure ) failing ,how to fix?文件共享删除(Azure)失败,如何解决?
【发布时间】:2022-10-22 18:55:36
【问题描述】:

我有一段代码迭代文件共享并删除文件共享,而删除它可能包含快照,我该如何删除文件共享,因为它不断失败并出现错误消息,如。“无法删除文件共享,因为一个或多个共享快照具有活动租约,注意:我看不到任何让我知道租约 ID 的属性,甚至快照时间为空。在 Portal 上,存储帐户级别有一个删除锁,它是否限制文件共享的删除?

using Microsoft.WindowsAzure.Storage
string storageconnectionstring = "Storage Account connection string";
CloudStorageAccount c = CloudStorageAccount.Parse(storageconnectionstring);
CloudFileClient fileclient= c.CreateCloudFileClient();


foreach(var x in fileclient.ListShares()) {

x.DeleteIfExists(DeleteShareSnapshotsoptions.IncludeSnapshots ,AccessCondition.GenerateEmpty(),
new FileRequestOptions(), new OperationContext())----> This code is failing

}

【问题讨论】:

    标签: c# azure azure-file-share


    【解决方案1】:

    我在我的环境中尝试并得到以下结果:

    “无法删除文件共享,因为一个或多个共享快照具有活动租约,

    错误显示在您的File-share有一些活动快照,因此无法删除。

    我尝试在我的环境中使用一段代码来删除快照。

    您可以使用 **azure.storage.files.share** 包来删除快照。

    代码:

    using Azure.Storage.Files.Shares;
    
    namespace fileshare
    {
        class program
        {
            public static void Main()
            {
                var connectionString = "DefaultEndpointsProtocol=https;AccountName=<Account name>;AccountKey=<Account key >==;EndpointSuffix=core.windows.net";
                var shareName = "share1";
                var snapshot = "2022-10-22T10:23:02.0000000Z";
                ShareServiceClient shareserviceclient = new ShareServiceClient(connectionString);
                ShareClient shareClient = shareserviceclient.GetShareClient(shareName).WithSnapshot(snapshot);
                shareClient.Delete();
            }
        }
    }
    

    回复:

    门户网站:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-19
      • 2020-10-07
      • 2019-01-26
      • 2019-11-14
      • 2021-12-06
      • 2021-10-20
      • 2021-12-23
      相关资源
      最近更新 更多