Harsh
Harsh

Reputation: 159

Start-AzureStorageBlobCopy :The remote server returned an error: (409) Conflict. HTTP Status Code: There is currently a pending copy operation

I am trying to copy the folders from one Container of Azure Storage account to Another container of axure Storage account using AzureStorageBlobCopy.

While copying I noticed the below error occurs for blob files which has snapshots present. And in destination only Snapshot exists instead of latest copy from source for the files for which I receive this error.

Start-AzureStorageBlobCopy : The remote server returned an error: (409) Conflict. HTTP Status Code: 409 - HTTP Error Message: There is currently a pending copy operation.

I already tried using -Force Parameter in AzureStorageBlobCopy but it did not work.

Below is my code which I am running.

$SourceStorageAccountName = 'cloudshell2117008638'
$sourceStorageAccountKey = 'ACC_KEY'
$DestinationStorageAccountName = 'storageaccdest'
$destinationStorageAccountKey = 'ACC_KEY2'
$SourceContainerName = 'consrc'
$DestinationContainerName = 'condest'

$sourceContext = New-AzureStorageContext -StorageAccountName $SourceStorageAccountName -StorageAccountKey $sourceStorageAccountKey
$destinationContext = New-AzureStorageContext -StorageAccountName $DestinationStorageAccountName -StorageAccountKey $destinationStorageAccountKey 

$blobs = Get-AzureStorageBlob -Context $sourceContext -Container $SourceContainerName

$blobs | Start-AzureStorageBlobCopy -Context $sourceContext -DestContext $destinationContext -DestContainer $DestinationContainerName

I need to copy all the files as it is from the source container without error being faced.

enter image description here

Upvotes: 2

Views: 1697

Answers (1)

Joey Cai
Joey Cai

Reputation: 20067

When you start, the copy is in progress, we need to know when this is complete so we can continue. If we just run the command you provided, you can see that PowerShell returns a result immediately making you think the copy has completed. Well, not exactly. You can see that the Status is actually Pending. If you tried to run your ARM template you would get an error stating that the blob could not be found.

We could include the -WaitForComplete parameter to actually see the status of the copy and we’ll be able to know when it has completed as seen in the screenshot below. Refer to this article.

Get-AzureStorageBlobCopyState -Container "destcontainer" -Context $destinationContext -WaitForComplete

enter image description here

Upvotes: 1

Related Questions