I'm trying to copy files from one file directory in Azure Storage Explorer to a sub-directory of the source files directory.
I initially wanted to use AZcopy to copy the files over, but Azcopy doesnt support copying files to a sub-directory.
So now I'm going the Powershell route, using Start-AzStorageFileCopy cmdlet.
Below is my full script
$context = New-AzStorageContext -StorageAccountName "store1" -SasToken "?
sv=2015-12-11&si=aaa-15D97F9B09D&sr=s&sig=xxx"
# Since the file name has date, you can specify which date to be deleted.
# In this sample, we try to delete the files' name contains previous
datemonth string eg. "201901"
$pattern =[datetime]::Today.AddMonths(-2).ToString('yyyyMM')
$ShareName = "aaa"
$SourcePath = "Test/Temp_Clean_up_test_Folder"
$ArchivePath = "Test/Temp_Clean_up_test_Folder/Archive/"+
[datetime]::Today.AddMonths(-2).ToString('yyyyMM')
Get-AzStorageFile -ShareName "aaa" -Path "Test/Temp_Clean_up_test_Folder" -
Context $context | Get-AzStorageFile | where {($_.GetType().Name -eq
"CloudFile") -and ($_.Name -like "*$pattern*")} | Start-AzStorageFileCopy -
DestFilePath $ArchivePath -DestShareName "aaa" -SrcFile {$_} -DestContext
$Context
I expect the files to copy over, but I receive the following error.
Start-AzStorageFileCopy : The specified resource does not exist. HTTP Status >Code: 404 - HTTP Error Message: The specified resource does not exist. At line:18 char:201 + ... ttern*")} | Start-AzStorageFileCopy -DestFilePath $ArchivePath -DestS >... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Start-AzStorageFileCopy], >StorageException + FullyQualifiedErrorId : >StorageException,Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.StartAzur>eStorageFileCopyCommand
Start-AzStorageFileCopy : The specified resource does not exist. HTTP Status >Code: 404 - HTTP Error Message: The specified resource does not exist. At line:18 char:201 + ... ttern*")} | Start-AzStorageFileCopy -DestFilePath $ArchivePath -DestS >... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Start-AzStorageFileCopy], >StorageException + FullyQualifiedErrorId : >StorageException,Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.StartAzur>eStorageFileCopyCommand
NOTES:
The Destination directory already exists.
The Source files Exist (I tested the output before I use Start-azStorageFileCopy Cmdlet)
I added
-DefaultProfile $Context
to the end of the script, hoping this would solve the issue, but it returned the same error.