Search code examples
azurepowershellazure-storageazure-powershell

Powershell error Remove-AzureStorageBlob Method not found: 'Void


enter image description here enter image description here

Getting Error while calling Remove-AzureStorageBlob Powershell

Remove-AzureStorageBlob -Container $ConName -Blob $BlobName -Context $Ctx
Remove-AzureStorageBlob : Method not found: 'Void
Microsoft.WindowsAzure.Storage.OperationContext.set_StartTime(System.DateTime)'.
At line:1 char:1
+ Remove-AzureStorageBlob -Container $ConName -Blob $BlobName -Context  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Remove-AzureStorageBlob], StorageException
    + FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.RemoveStorageAzureBlobComm
   and

Solution

  • Your commands belong to the AzureRM powershell module. According to the error message, you may not install it, I can reproduce your issue on my side.

    enter image description here

    To fix the issue, follow this doc to install AzureRM powershell module, then it will work fine : https://learn.microsoft.com/en-us/powershell/azure/azurerm/install-azurerm-ps?view=azurermps-6.13.0

    Besides, the AzureRM module has been deprecated basically, I recommand you to use the new Az module. For more details, see : https://azure.microsoft.com/en-us/blog/azure-powershell-cross-platform-az-module-replacing-azurerm/ and https://learn.microsoft.com/en-us/powershell/azure/new-azureps-module-az?view=azps-1.2.0.