Azcopy Not Transferring Any Files
So My Copy Line Looks Like This. .\Azcopy Copy $Source $Destination --Recursive=True Where $Source Is a List I Iterate Through in a for Each Loop. and...
So my copy line looks like this.
.\azcopy copy $source $destination --recursive=TRUE
Where $source is a list I iterate through in a for each loop. And destination is a Uri containing sas which is retrieved by another function.
My sources are network shared folders like so:
$Sources = @(
'\\computer\folder name\folder\*.zip',
)
A list of about five file paths on the same remote machine.
I'm troubleshooting with just the first filepath with the *.zip and there is a folder with a space in the middle like displayed.
My problem is that it all seems to run fine, but doesn't transfer any files and doesn't detect and files to transfer. There is one zipped folder in there.
Files to transfer = 0
Log file contains no errors and states that it completed successfully.
Any ideas?
F.y.i it works fine when running against a local file not a remote FileShare.
2 Answers
You can't use hastables in the format that you are using instead you should be using arrays.
Example :
$hashtable = @{
1="\\server\sharename\path\file"
2="\\server\sharename\path\file"
}
$array=@(
"\\server\sharename\path\file"
"\\server\sharename\path\file"
)
I tested the same requirement in my environment where I have a file share mapped to my machine like below :
There are two ways to perform a copy using azcopy from netowrk share to azure storage container :
Solution 1 using UNC path :
$destination= ""
$Sources = @(
"\\cloudshellansuman.file.core.windows.net\ansutest\testzipfolder\*.zip"
"\\cloudshellansuman.file.core.windows.net\ansutest\testdocfolder\AADSTS54005.docx"
)
ForEach($Source in $Sources){
.\azcopy copy $Source $destination --recursive=true
}
Solution 2 using Mapped Drive if the above doesn't work :
$destination= ""
$Sources = @(
'Z:\testdocfolder\AADSTS54005.docx'
'Z:\testzipfolder/*.zip'
)
ForEach($Source in $Sources){
.\azcopy copy $Source $destination --recursive=true
}
Output:
Note: I am using azcopy version 10.13.0
The solution was that the share path wasn't working but using the full unc path worked. So \\computer\folder2 might be set up as a share but it wouldn't work till I out \\computer\C$\folder1\folder2. So full path to each source not the path youd expect just to reach the share if you were going to it in file browser.