We were using AzureFileCopy to transfer files to a VM. The latest release has introduced a bug which means you receive an error when trying to do this. Apparently the url and the SAS token should have a ? between them but this has been missed out. I have reported the issue.
A solution was to break the task into two, one to copy the file to a storage account and a second to use azcopy to copy the storage blob data to the VM.
This was working for a spell but last week azcopy has started to fail reporting that:
azcopy : The term 'azcopy' is not recognized as the name of a cmdlet, function, script file, or...
The task in the release is PowerShell on Target Machines and the inline script is literally calling azcopy with parameters.
At present we can't release any of our software as it is dependent on this step to configure the VM.
Things we have tried to resolve this:
From your description, you are using the PowerShell on Target Machines task to run the Azcopy command.
The task will use the VM environment to run the Azcopy command. You need to install Azcopy Tool to the VM to complete the operation.
You can add the download/extract azcopy command to the PowerShell on Target Machines task.
For example:
PowerShell script:
Invoke-WebRequest -Uri 'https://azcopyvnext.azureedge.net/release20220315/azcopy_windows_amd64_10.14.1.zip' -OutFile 'azcopyv10.zip'
Expand-archive -Path '.\azcopyv10.zip' -Destinationpath '.\'
$AzCopy = (Get-ChildItem -path '.\' -Recurse -File -Filter 'azcopy.exe').FullName
# Invoke AzCopy
& $AzCopy xxxxxx
PowerShell on Target Machines task
- task: PowerShellOnTargetMachines@3
displayName: 'Run PowerShell on Target Machines'
inputs:
Machines: XX
UserName: XX
UserPassword: 'XX'
InlineScript: |
Invoke-WebRequest -Uri 'https://azcopyvnext.azureedge.net/release20220315/azcopy_windows_amd64_10.14.1.zip' -OutFile 'azcopyv10.zip'
Expand-archive -Path '.\azcopyv10.zip' -Destinationpath '.\'
$AzCopy = (Get-ChildItem -path '.\' -Recurse -File -Filter 'azcopy.exe').FullName
# Invoke AzCopy
& $AzCopy XXXX
The download and extract command only need to execute once. In the next runs, you can directly use the following powershell command to use the azcopy
$AzCopy = (Get-ChildItem -path '.\' -Recurse -File -Filter 'azcopy.exe').FullName
# Invoke AzCopy
& $AzCopy xxxxxx
For more detailed info, you can refer to the doc: PowerShellOnTargetMachines@3 - PowerShell on target machines v3 task and Use script to download Azcopy