0

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Glad to know that your issue has resolved. After 48 hours, you can accept it as answer( click on the check mark beside the answer to toggle it from greyed out to filled in). This can be beneficial to other community members. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.