0
votes

I can copy some file from Azure File Share to a Blob storage account with AzCopy. However, as this code needs to run in an automation runbook, I need another solution.

I am trying to use Start-AzStorageBlobCopy:

$sourcePathWithSasToken = $AzSourceFileShareDirectory.CloudFileDirectory.Uri.AbsoluteUri + $SourceStorageAccountSasToken
$targetSaContextWithSasToken = New-AzStorageContext -StorageAccountName $targetSaName -SasToken $TargetStorageAccountSasToken

Start-AzStorageBlobCopy `
  -Context $SourceStorageAccountContext `
  -AbsoluteUri $sourcePathWithSasToken `
  -DestContext $targetSaContextWithSasToken `
  -DestContainer $targetContainerName `
  -DestBlob $fileName

However, I get:

WARNING: Ignore mismatch source storage context.. The source uri is https://SOURCEaccountname.file.core.windows.net/ccbifilesyncshare1/?token, the end point is https://SOURCEaccountname.blob.core.windows.net/.

Or is this just not possible? According to the Microsoft docs, the other way around, from blob to file should be possible. However, I cannot really find an example of File Share to Blob.

If I am correct, Start-AzStorageFileCopy is definitely not able to perform this action.

Thanks in advance!!

1

1 Answers

1
votes

Ok, suddenly, my nth try worked!

$targetSaContextWithSasToken = New-AzStorageContext -StorageAccountName $targetSaName -SasToken $TargetStorageAccountSasToken
$srcFilePath = $shareFolder + "/" + $fileName

Start-AzStorageBlobCopy `
  -Context $SourceStorageAccountContext `
  -SrcShareName $AzSourceFileShareName `
  -SrcFilePath $srcFilePath `
  -DestContext $targetSaContextWithSasToken `
  -DestContainer $targetContainerName `
  -DestBlob $fileName

I removed the absolute URI and added sharename and file path.

I tried this before, but using various "wrong" file paths. So, it requires: folder/file name.