@@ -22,25 +22,68 @@ try {
22
22
$removeTimeoutSec = Get-VstsInput - Name removeTimeoutSec
23
23
$getStatusTimeoutSec = Get-VstsInput - Name getStatusTimeoutSec
24
24
25
- $deployParameters = @ {
26
- ' ApplicationName' = $applicationName
27
- ' Compose' = $composeFilePath
28
- }
29
- $removeParameters = @ {
30
- ' Force' = $true
31
- }
32
- $getStatusParameters = @ {
33
- ' ApplicationName' = $applicationName
34
- }
35
-
36
- $usePreviewApi = $false
37
- $regKey = Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Service Fabric\' - ErrorAction SilentlyContinue
25
+ $apiVersion = ' 2.8'
26
+ $regKey = Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Service Fabric SDK\' - ErrorAction SilentlyContinue
38
27
if ($regKey )
39
28
{
40
- if ($regKey.FabricVersion.StartsWith (' 255.255' ))
29
+ if ($regKey.FabricSDKVersion -match " ^\d+\.\d+" )
30
+ {
31
+ $regExVersion = $matches [0 ]
32
+
33
+ switch ($regExVersion ) {
34
+ ' 2.7' { $apiVersion = ' 2.7' }
35
+ ' 2.8' { $apiVersion = ' 2.8' }
36
+ ' 255.255' { $apiVersion = ' 255.255' }
37
+ Default {
38
+ $sdkVersion = New-Object Version
39
+ if ([Version ]::TryParse($matches [0 ], [ref ]$sdkVersion )) {
40
+ $minVersion = New-Object - TypeName Version - ArgumentList ' 2.7'
41
+ if ($sdkVersion -lt $minVersion ) {
42
+ Write-Error (Get-VstsLocString - Key UnsupportedAPIVersion - ArgumentList $regKey.FabricSDKVersion )
43
+ return ;
44
+ }
45
+ }
46
+ else {
47
+ Write-Error (Get-VstsLocString - Key UnsupportedAPIVersion - ArgumentList $regKey.FabricSDKVersion )
48
+ return ;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ else
41
54
{
42
- $usePreviewApi = $true
43
- Write-Verbose (Get-VstsLocString - Key UsingPreviewAPI)
55
+ Write-Error (Get-VstsLocString - Key UnsupportedAPIVersion - ArgumentList $regKey.FabricSDKVersion )
56
+ return ;
57
+ }
58
+ }
59
+ Write-Verbose (Get-VstsLocString - Key UsingAPIVersion - ArgumentList $apiVersion )
60
+
61
+ if ($apiVersion -eq ' 2.8' )
62
+ {
63
+ $deployParameters = @ {
64
+ ' DeploymentName' = $applicationName
65
+ ' Compose' = $composeFilePath
66
+ }
67
+ $removeParameters = @ {
68
+ ' DeploymentName' = $applicationName
69
+ ' Force' = $true
70
+ }
71
+ $getStatusParameters = @ {
72
+ ' DeploymentName' = $applicationName
73
+ }
74
+ }
75
+ else
76
+ {
77
+ $deployParameters = @ {
78
+ ' ApplicationName' = $applicationName
79
+ ' Compose' = $composeFilePath
80
+ }
81
+ $removeParameters = @ {
82
+ ' ApplicationName' = $applicationName
83
+ ' Force' = $true
84
+ }
85
+ $getStatusParameters = @ {
86
+ ' ApplicationName' = $applicationName
44
87
}
45
88
}
46
89
93
136
}
94
137
}
95
138
96
- if ($usePreviewApi )
139
+ if ($apiVersion -eq ' 255.255 ' )
97
140
{
98
141
$deployParameters [' RepositoryUserName' ] = $username
99
142
$deployParameters [' RepositoryPassword' ] = $password
@@ -120,49 +163,47 @@ try {
120
163
$getStatusParameters [' TimeoutSec' ] = $getStatusTimeoutSec
121
164
}
122
165
123
- $existingApplication = Get-ServiceFabricComposeApplicationStatusHelper - UsePreviewAPI $usePreviewAPI - GetStatusParameters $getStatusParameters
166
+ $existingApplication = Get-ServiceFabricComposeApplicationStatusHelper - ApiVersion $apiVersion - GetStatusParameters $getStatusParameters
124
167
if ($existingApplication -ne $null )
125
168
{
126
169
Write-Host (Get-VstsLocString - Key RemovingApplication - ArgumentList $applicationName )
127
- $removeParameters [' ApplicationName' ] = $applicationName
128
- Remove-ServiceFabricComposeApplication @removeParameters
129
170
171
+ Remove-ServiceFabricComposeApplicationHelper - ApiVersion $apiVersion - RemoveParameters $removeParameters
130
172
do
131
173
{
132
- Write-Host (Get-VstsLocString - Key CurrentStatus - ArgumentList $existingApplication.ComposeApplicationStatus )
174
+ Write-Host (Get-VstsLocString - Key CurrentStatus - ArgumentList $existingApplication.Status )
133
175
Start-Sleep - Seconds 3
134
- $existingApplication = Get-ServiceFabricComposeApplicationStatusHelper - UsePreviewAPI $usePreviewAPI - GetStatusParameters $getStatusParameters
135
-
176
+ $existingApplication = Get-ServiceFabricComposeApplicationStatusHelper - ApiVersion $apiVersion - GetStatusParameters $getStatusParameters
136
177
}
137
178
while ($existingApplication -ne $null )
138
179
Write-Host (Get-VstsLocString - Key ApplicationRemoved)
139
180
}
140
181
141
182
Write-Host (Get-VstsLocString - Key CreatingApplication)
142
- New-ServiceFabricComposeApplication @ deployParameters
183
+ New-ServiceFabricComposeApplicationHelper - ApiVersion $apiVersion - DeployParameters $ deployParameters
143
184
144
185
Write-Host (Get-VstsLocString - Key WaitingForDeploy)
145
- $newApplication = Get-ServiceFabricComposeApplicationStatusHelper - UsePreviewAPI $usePreviewAPI - GetStatusParameters $getStatusParameters
186
+ $newApplication = Get-ServiceFabricComposeApplicationStatusHelper - ApiVersion $apiVersion - GetStatusParameters $getStatusParameters
146
187
while (($newApplication -eq $null ) -or `
147
- ($newApplication.ComposeApplicationStatus -eq ' Provisioning' ) -or `
148
- ($newApplication.ComposeApplicationStatus -eq ' Creating' ))
188
+ ($newApplication.Status -eq ' Provisioning' ) -or `
189
+ ($newApplication.Status -eq ' Creating' ))
149
190
{
150
191
if ($newApplication -eq $null )
151
192
{
152
193
Write-Host (Get-VstsLocString - Key WaitingForDeploy)
153
194
}
154
195
else
155
196
{
156
- Write-Host (Get-VstsLocString - Key CurrentStatus - ArgumentList $newApplication.ComposeApplicationStatus )
197
+ Write-Host (Get-VstsLocString - Key CurrentStatus - ArgumentList $newApplication.Status )
157
198
}
158
199
Start-Sleep - Seconds 3
159
- $newApplication = Get-ServiceFabricComposeApplicationStatusHelper - UsePreviewAPI $usePreviewAPI - GetStatusParameters $getStatusParameters
200
+ $newApplication = Get-ServiceFabricComposeApplicationStatusHelper - ApiVersion $apiVersion - GetStatusParameters $getStatusParameters
160
201
}
161
- Write-Host (Get-VstsLocString - Key CurrentStatus - ArgumentList $newApplication.ComposeApplicationStatus )
202
+ Write-Host (Get-VstsLocString - Key CurrentStatus - ArgumentList $newApplication.Status )
162
203
163
- if ($newApplication.ComposeApplicationStatus -ne ' Created' )
204
+ if ($newApplication.Status -ne ' Created' -and $newApplication .Status -ne ' Ready ' )
164
205
{
165
- Write-Error (Get-VstsLocString - Key DeployFailed - ArgumentList @ ($newApplication.ComposeApplicationStatus .ToString (), $newApplication.StatusDetails ))
206
+ Write-Error (Get-VstsLocString - Key DeployFailed - ArgumentList @ ($newApplication.Status .ToString (), $newApplication.StatusDetails ))
166
207
}
167
208
} finally {
168
209
Trace-VstsLeavingInvocation $MyInvocation
0 commit comments