I'm trying to copy an entire folder/blob from an azure adls gen2 container in one subscription to another subscription.
Before the below code I've already connected to azure and populated hash tables of each subscription detail.
Set-AzContext -Subscription $DevDetails.SubscriptionID
$DevStorageAccount = Get-AzStorageAccount -ResourceGroupName $DevDetails.ResourceGroup -StorageAccountName $DevDetails.StorageAccount
$DevContext = New-AzStorageContext -StorageAccountName $DevDetails.StorageAccount
$DevStorageContainer = Get-AzStorageContainer -Name "raw" -Context $DevContext
Set-AzContext -Subscription $PPDetails.SubscriptionID
$PPStorageAccount = Get-AzStorageAccount -ResourceGroupName $PPDetails.ResourceGroup -StorageAccountName $PPDetails.StorageAccount
$PPContext = New-AzStorageContext -StorageAccountName $PPDetails.StorageAccount
$PPStorageContainer = Get-AzStorageContainer -Name "raw" -Context $PPContext
Set-AzContext -Subscription $ProdDetails.SubscriptionID
$PStorageAccount = Get-AzStorageAccount -ResourceGroupName $ProdDetails.ResourceGroup -StorageAccountName $ProdDetails.StorageAccount
$PContext = New-AzStorageContext -StorageAccountName $ProdDetails.StorageAccount
$PStorageContainer = Get-AzStorageContainer -Name "raw" -Context $PContext
I've got the variables for context for all 3 environments.
In the prod storagecontainer raw we have a gen 2 folder in a hierarchical namespace. (Folder1/Folder2/Folder3)
I would like to copy the folder and all contents from prod back to dev. Trying this command.
Start-AzStorageBlobCopy -DestContainer $DevStorageContainer.Name -Context $PContext -SrcBlob "Folder1/Folder2/Folder3/" -SrcContainer $PStorageContainer.Name -DestContext $DevContext
I get the error
Status: 403 (This request is not authorized to perform this operation.)
ErrorCode: CannotVerifyCopySource
I've also tried this.
$prodblob = Get-AzStorageBlob -Context $PContext -Container $PStorageContainer.Name -Blob "Folder1/Folder2/Folder3/"
$prodblob | Start-AzStorageBlobCopy -DestContainer $DevStorageContainer.Name -Context $DevContext
which gives the same error.
I'm able to copy it manually across using azure storage explorer and also able to do it using azcopy so it doesn't seem to be a permission issue.
Is this just not compatible with adls gen2 and I'm going about it completely wrong or is there something simple I'm missing?
azcopyor why did you want to useStart-AzStorageBlobCopy?