@@ -42,13 +42,24 @@ $additionalArgumentsForVMCopy = $additionalArgumentsForVMCopy.Trim()
4242$useDefaultArgumentsForBlobCopy = ($additionalArgumentsForBlobCopy -eq " " )
4343
4444# Determine AzCopy version based on Az.Accounts version
45- $azCopyExeLocation = ' AzCopy\AzCopy.exe'
46-
45+ $azCopyExeLocation = ' AzCopy_Prev\AzCopy\AzCopy.exe'
46+ function Get-azCopyExeLocation
47+ {
48+ param ([string ]$location )
49+ if ($location -eq ' latest' ) {
50+ Write-Verbose " Using AzCopy (10.29.1) - Az.Accounts >= 5.0.0"
51+ return ' AzCopy\AzCopy.exe'
52+ } else {
53+ Write-Verbose " Using AzCopy_Prev (10.25.1) - Az.Accounts < 5.0.0"
54+ return ' AzCopy_Prev\AzCopy\AzCopy.exe'
55+ }
56+ }
4757# Command to run in PowerShell Core (returns version only)
4858$coreCommand = ' (Get-Module -Name Az.Accounts -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Version.ToString()'
4959# Locate pwsh.exe
5060$pwshPath = Get-Command pwsh.exe - ErrorAction SilentlyContinue
51-
61+ # if FF enable use latest azcopy as default
62+ $UseLatestAzCopyAsDefault = Get-VstsPipelineFeature - FeatureName ' UseLatestAzCopyAsDefault'
5263if ($pwshPath ) {
5364 Write-Verbose " Found PowerShell Core. Querying Az.accounts module version..."
5465
@@ -57,29 +68,38 @@ if ($pwshPath) {
5768
5869 # Convert to a single string, then trim
5970 $cleanVersion = ($azAccountsVersionCore -join ' ' ).Trim()
71+
72+ Write-Verbose " Az.Accounts version: $cleanVersion "
6073
6174 if ($cleanVersion -and $cleanVersion -ne " NotFound" ) {
6275 try {
6376 $parsedVersion = [version ]$cleanVersion
6477
6578 if ($parsedVersion -ge [version ]' 5.0.0' ) {
66- $azCopyExeLocation = ' AzCopy\AzCopy.exe'
67- Write-Verbose " Using AzCopy (10.29.1) - Az.Accounts >= 5.0.0"
79+ $azCopyExeLocation = Get-azCopyExeLocation - location " latest"
6880 } else {
69- $azCopyExeLocation = ' AzCopy_Prev\AzCopy\AzCopy.exe'
70- Write-Verbose " Using AzCopy_Prev (10.25.1) - Az.Accounts < 5.0.0"
81+ $azCopyExeLocation = Get-azCopyExeLocation - location " previous"
7182 }
7283 } catch {
73- Write-Error " Failed to parse Az.Accounts version: $cleanVersion "
84+ Write-Verbose " Failed to parse Az.Accounts version: $cleanVersion "
85+ if ($UseLatestAzCopyAsDefault -eq $true ) {
86+ $azCopyExeLocation = Get-azCopyExeLocation - location " latest"
87+ }
7488 }
7589 }
7690 else {
77- Write-Output " Az.Accounts not found in PowerShell Core"
91+ Write-Verbose " Az.Accounts not found in PowerShell Core"
92+ if ($UseLatestAzCopyAsDefault -eq $true ) {
93+ $azCopyExeLocation = Get-azCopyExeLocation - location " latest"
94+ }
7895 }
79-
8096} else {
8197 Write-Error " PowerShell Core (pwsh.exe) is not installed or not found in PATH."
98+ if ($UseLatestAzCopyAsDefault -eq $true ) {
99+ $azCopyExeLocation = Get-azCopyExeLocation - location " latest"
100+ }
82101}
102+
83103$azCopyLocation = [System.IO.Path ]::GetDirectoryName($azCopyExeLocation )
84104
85105# Import RemoteDeployer
0 commit comments