gpt4 book ai didi

azure - Powershell - 删除容器中的所有 Blob

转载 作者:行者123 更新时间:2023-12-02 23:52:00 26 4
gpt4 key购买 nike

在备份到特定容器之前,我需要删除该容器中的所有 blob。以下不起作用。执行此操作的正确方法是什么?

Get-AzStorageBlob -Container $ContainerName -Context $ctx |  Remove-AzStorageBlob -DeleteSnapshot -Force

对于 Get-AzStorageBlob 返回的每个 blob,我收到以下错误消息:

Remove-AzStorageBlob : The specified blob does not exist. HTTP Status Code: 404 - HTTP Error Message: The specified blob does not exist.
ErrorCode: BlobNotFound
ErrorMessage: The specified blob does not exist.
RequestId:eb2612f4-f01e-0067-5471-3e9f69000000
Time:2019-07-19T20:33:50.1261168Z
At line:15 char:62
+ ... inerName -Context $ctx | Remove-AzStorageBlob -DeleteSnapshot -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Remove-AzStorageBlob], StorageException
+ FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.RemoveStorageAzureBlobCommand

最佳答案

我用你的ps脚本测试了一下,是-DeleteSnapshot -Force引起的,删除就可以了。

Get-AzureStorageBlob -Container $ContainerName -Context $ctx | Remove-AzureStorageBlob

enter image description here

如果你想删除快照,只需添加-Force即可。这是Parameters description , -Force 表示此 cmdlet 无需确认即可删除 Blob 及其快照。

你可以尝试一下,希望对你有帮助。

注意:如果您使用的是较新的 Az Module,上面的代码将如下所示:

Get-AzStorageBlob -Container $ContainerName -Context $ctx |删除-AzStorageBlob

关于azure - Powershell - 删除容器中的所有 Blob ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57119087/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com