Remove-AzureStorageBlob在Runbook中不起作用

时间:2015-02-03 16:11:29

标签: powershell azure-storage-blobs

为什么以下powershell-code在我的本地计算机上运行良好,但在Azure自动化Runbook中执行时却失败了?

Get-AzureStorageBlob -Container "workloads" -Prefix "aaa" | Remove-AzureStorageBlob

运行手册-差错消息

Remove-AzureStorageBlob : The input object cannot be bound to any parameters for the command either because the command 
does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline 
input.
At Remove-CID:116 char:116
+ 
    + CategoryInfo          : InvalidArgument: (Microsoft.Windo...zureStorageBlob:PSObject) [Remove-AzureStorageBlob],  ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.WindowsAzure.Commands.Storage.Blob.RemoveStorageAzureBlobCommand

1 个答案:

答案 0 :(得分:0)

笨拙,但它有效

$blobs = Get-AzureStorageBlob -Container $container -Prefix "aaa"

foreach($blob in $blobs)
{
    Remove-AzureStorageBlob -Blob $blob.Name -Container $container
}

找到here