File tree Expand file tree Collapse file tree 6 files changed +52
-18
lines changed Expand file tree Collapse file tree 6 files changed +52
-18
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,21 @@ $additionalArgumentsForBlobCopy = $additionalArgumentsForBlobCopy.Trim()
4141$additionalArgumentsForVMCopy = $additionalArgumentsForVMCopy.Trim ()
4242$useDefaultArgumentsForBlobCopy = ($additionalArgumentsForBlobCopy -eq " " )
4343
44- # azcopy location on automation agent
44+ # Determine AzCopy version based on Az.Accounts version
4545$azCopyExeLocation = ' AzCopy\AzCopy.exe'
46+ $azAccountsModule = Get-Module - Name Az.Accounts - ListAvailable | Sort-Object Version - Descending | Select-Object - First 1
47+ if ($null -eq $azAccountsModule -or ([version ]$azAccountsModule.Version -ge [version ]' 5.0.0' )) {
48+ # Use latest AzCopy
49+ $azCopyExeLocation = ' AzCopy\AzCopy.exe'
50+ Write-Verbose " Using AzCopy (10.29.1) - Az.Accounts not found or >= 5.0.0"
51+ } else {
52+ # Use previous AzCopy
53+ $azCopyExeLocation = ' AzCopy_Prev\AzCopy\AzCopy.exe'
54+ Write-Verbose " Using AzCopy_Prev (10.25.1) - Az.Accounts < 5.0.0"
55+ }
4656$azCopyLocation = [System.IO.Path ]::GetDirectoryName($azCopyExeLocation )
4757
58+
4859# Import RemoteDeployer
4960Import-Module $PSScriptRoot \ps_modules\RemoteDeployer
5061
Original file line number Diff line number Diff line change @@ -99,5 +99,8 @@ describe('AzureFileCopy Suite', function () {
9999 it ( 'Validate AzureFileCopy.Utility Check-ContainerNameAndArgs' , ( done ) => {
100100 psr . run ( path . join ( __dirname , 'L0CheckContainerNameAndArgs.ps1' ) , done ) ;
101101 } ) ;
102+ it ( 'Validate AzCopy version selection and E2E upload' , ( done ) => {
103+ psr . run ( path . join ( __dirname , 'L0AzCopyVersionSelection.ps1' ) , done ) ;
104+ } ) ;
102105 }
103106} ) ;
Original file line number Diff line number Diff line change 1+ [CmdletBinding ()]
2+ param ()
3+
4+ . $PSScriptRoot \..\..\..\Tests\lib\Initialize-Test.ps1
5+ . $PSScriptRoot \MockVariable.ps1
6+ . $PSScriptRoot \MockHelper.ps1
7+
8+ Unregister-Mock Get-Module
9+
10+ # Mock Get-Module to simulate Az.Accounts version 4.7.0
11+ Register-Mock Get-Module {
12+ [PSCustomObject ]@ { Version = [version ]' 4.7.0' }
13+ }
14+
15+ # Simulate script logic (manually call logic block under test)
16+ $azCopyExeLocation = ' AzCopy\AzCopy.exe'
17+ $azAccountsModule = Get-Module - Name Az.Accounts - ListAvailable | Sort-Object Version - Descending | Select-Object - First 1
18+ if ($null -eq $azAccountsModule -or ([version ]$azAccountsModule.Version -ge [version ]' 5.0.0' )) {
19+ $azCopyExeLocation = ' AzCopy\AzCopy.exe'
20+ } else {
21+ $azCopyExeLocation = ' AzCopy_Prev\AzCopy\AzCopy.exe'
22+ }
23+
24+ # Assert value
25+ Assert-AreEqual ' AzCopy_Prev\AzCopy\AzCopy.exe' $azCopyExeLocation ' AzCopyExeLocation should be previous AzCopy when Az.Accounts < 5.0.0'
Original file line number Diff line number Diff line change 11{
2- "rm" : [
2+ "rm" : [
33 {
4- "items" : [
5- " node_modules/https-proxy-agent/node_modules/agent-base" ,
6- " node_modules/azure-pipelines-tasks-azure-arm-rest/node_modules/agent-base"
7- ],
8- "options" : " -Rf"
4+ "items" : [
5+ " node_modules/https-proxy-agent/node_modules/agent-base" ,
6+ " node_modules/azure-pipelines-tasks-azure-arm-rest/node_modules/agent-base"
7+ ],
8+ "options" : " -Rf"
99 }
1010 ],
1111
4040 {
4141 "url" : " https://vstsagenttools.blob.core.windows.net/tools/azcopy/10.29.1/AzCopy.zip" ,
4242 "dest" : " ./"
43+ },
44+ {
45+ "url" : " https://vstsagenttools.blob.core.windows.net/tools/azcopy/10.25.1/AzCopy.zip" ,
46+ "dest" : " AzCopy_Prev"
4347 }
4448 ],
4549 "nugetv2" : [
6973 "source" : " MimeMapping.json" ,
7074 "options" : " -R"
7175 }
72- ],
73- "rm" : [
74- {
75- "items" : [
76- " node_modules/azure-pipelines-tasks-azure-arm-rest/node_modules/agent-base" ,
77- " node_modules/https-proxy-agent/node_modules/agent-base"
78- ],
79- "options" : " -Rf"
80- }
8176 ]
8277}
Original file line number Diff line number Diff line change 1414 "version" : {
1515 "Major" : 6 ,
1616 "Minor" : 258 ,
17- "Patch" : 0
17+ "Patch" : 2
1818 },
1919 "demands" : [
2020 " azureps"
Original file line number Diff line number Diff line change 1414 "version" : {
1515 "Major" : 6 ,
1616 "Minor" : 258 ,
17- "Patch" : 0
17+ "Patch" : 2
1818 },
1919 "demands" : [
2020 " azureps"
You can’t perform that action at this time.
0 commit comments