Reputation: 197
I read the following link for copying files from VM to the azure blob storage account. However, if i need to copy it to designated folder in the container, say, containerName/UserA/Report/A and containerName/UserA/Report/B according to the file name in VM.What will be the command look like? Thanks for your help.
Powershell script to copy files from server to azure blob container
Upvotes: 0
Views: 1079
Reputation: 136346
You can prepend the desired path to the file name to set the name of the blob. Something like:
$context = New-AzStorageContext -StorageAccountName "<StorageAccountName>" -StorageAccountKey "<StorageAccountKey>"
$files = (Get-ChildItem "C:\Users\xxxx\Desktop\test" -recurse).FullName
foreach($file in $files){
$blobName = "UserA/Report/$file"
Set-AzStorageBlobContent -Context $context -File "$file" -Container "<container name>" -Blob $blobName
}
Upvotes: 1