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!!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.