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!!