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()
41
41
$additionalArgumentsForVMCopy = $additionalArgumentsForVMCopy.Trim ()
42
42
$useDefaultArgumentsForBlobCopy = ($additionalArgumentsForBlobCopy -eq " " )
43
43
44
- # azcopy location on automation agent
44
+ # Determine AzCopy version based on Az.Accounts version
45
45
$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
+ }
46
56
$azCopyLocation = [System.IO.Path ]::GetDirectoryName($azCopyExeLocation )
47
57
58
+
48
59
# Import RemoteDeployer
49
60
Import-Module $PSScriptRoot \ps_modules\RemoteDeployer
50
61
Original file line number Diff line number Diff line change @@ -99,5 +99,8 @@ describe('AzureFileCopy Suite', function () {
99
99
it ( 'Validate AzureFileCopy.Utility Check-ContainerNameAndArgs' , ( done ) => {
100
100
psr . run ( path . join ( __dirname , 'L0CheckContainerNameAndArgs.ps1' ) , done ) ;
101
101
} ) ;
102
+ it ( 'Validate AzCopy version selection and E2E upload' , ( done ) => {
103
+ psr . run ( path . join ( __dirname , 'L0AzCopyVersionSelection.ps1' ) , done ) ;
104
+ } ) ;
102
105
}
103
106
} ) ;
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 1
1
{
2
- "rm" : [
2
+ "rm" : [
3
3
{
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"
9
9
}
10
10
],
11
11
40
40
{
41
41
"url" : " https://vstsagenttools.blob.core.windows.net/tools/azcopy/10.29.1/AzCopy.zip" ,
42
42
"dest" : " ./"
43
+ },
44
+ {
45
+ "url" : " https://vstsagenttools.blob.core.windows.net/tools/azcopy/10.25.1/AzCopy.zip" ,
46
+ "dest" : " AzCopy_Prev"
43
47
}
44
48
],
45
49
"nugetv2" : [
69
73
"source" : " MimeMapping.json" ,
70
74
"options" : " -R"
71
75
}
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
- }
81
76
]
82
77
}
Original file line number Diff line number Diff line change 14
14
"version" : {
15
15
"Major" : 6 ,
16
16
"Minor" : 258 ,
17
- "Patch" : 0
17
+ "Patch" : 2
18
18
},
19
19
"demands" : [
20
20
" azureps"
Original file line number Diff line number Diff line change 14
14
"version" : {
15
15
"Major" : 6 ,
16
16
"Minor" : 258 ,
17
- "Patch" : 0
17
+ "Patch" : 2
18
18
},
19
19
"demands" : [
20
20
" azureps"
You can’t perform that action at this time.
0 commit comments