【问题标题】:Delete Blob file from the Azure Portal从 Azure 门户中删除 Blob 文件
【发布时间】:2023-03-06 10:31:02
【问题描述】:

我是 Azure DatabaseDB 的新手,我想检查上传到 blob 存储的文件,并从 portal.azure.com 中一一删除。

是否可以查看列表并将其从 portal.azure.com 中删除?

注意:我只是想删除存储在 blob 存储中的文件,而不是 Blob 存储。

【问题讨论】:

    标签: azure azure-storage azure-blob-storage blobstorage


    【解决方案1】:

    你也可以从你的 C# 代码中做到这一点-

    private CloudBlobContainer blobContainer;
    
    public void DeleteFile(string uniqueFileIdentifier)
    {
      this.AssertBlobContainer();
    
      var blob = this.blobContainer.GetBlockBlobReference(fileName);
      blob.DeleteIfExists();
    }
    
    private void AssertBlobContainer()
    {
    // only do once
    if (this.blobContainer == null)
    {
        lock (this.blobContainerLockObj)
        {
            if (this.blobContainer == null)
            {
                var client = this.cloudStorageAccount.CreateCloudBlobClient();
    
                this.blobContainer = client.GetContainerReference(this.containerName.ToLowerInvariant());
    
                if (!this.blobContainer.Exists())
                {
                    throw new CustomRuntimeException("Container {0} does not exist in azure account", containerName);
                }
            }
        }
    }
    
    if (this.blobContainer == null) throw new NullReferenceException("Blob Empty");
    }
    

    【讨论】:

    • 谢谢,我想从 portal.azure.com 中删除它,现在我找到了解决方案。
    • @VIVEK - OP 已经向您解释过 - 他们想要一个门户解决方案,而不是代码解决方案。而且您还假设他们正在使用 c#。这可能就是你投反对票的原因。
    • @VIVEK 否决票?这是免费的投票。我一直在寻找 C# 解决方案并偶然发现了这段有用的代码。感谢您的贡献。
    • 什么是 blobContainerLockObj?我不能得到这个工作。任何人都可以得到这项工作?
    【解决方案2】:

    我找到了解决方案。

    点击你的Storage Account -> 点击Containers => 选择Container => 点击File => 最后Delete

    ==============================================

    更新:

    Azure Storage Explorer 也提供相同的功能。从 Windows、macOS 或 Linux 随时随地轻松管理 Azure 云存储资源的免费工具

    上传、下载和管理 Azure Blob、文件、队列和表,以及 Azure Cosmos DB 和 Azure Data Lake Storage 实体。轻松访问虚拟机磁盘并使用 Azure 资源管理器或经典存储帐户。管理和配置跨域资源共享规则。

    谢谢。

    【讨论】:

    • 我只能在2天后标记它。但你可以upvote it ;)
    猜你喜欢
    • 2016-03-27
    • 2021-02-02
    • 2017-08-22
    • 2021-10-09
    • 2019-12-15
    • 1970-01-01
    • 2021-12-12
    • 2015-05-30
    • 2019-11-28
    相关资源
    最近更新 更多