Skip to content

Commit 644bf53

Browse files
authored
Merge pull request #1864 from Microsoft/users/chshrikh/LegacyHandlePort101
Users/chshrikh/legacy handle port101
2 parents 37ebb14 + 8242eee commit 644bf53

File tree

10 files changed

+28
-113
lines changed

10 files changed

+28
-113
lines changed

Tasks/DeployAzureResourceGroup/DeployAzureResourceGroup.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ $ErrorActionPreference = "Stop"
5757
# Import all the dlls and modules which have cmdlets we need
5858
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
5959
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Common"
60+
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs"
6061
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal"
6162

6263
# Load all dependent files for execution

Tasks/DeployAzureResourceGroup/Utility.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,16 +450,17 @@ function Instantiate-Environment
450450
Write-Verbose "Starting Register-Environment cmdlet call for resource group : $resourceGroupName"
451451
if((gcm Register-Environment).Parameters.ContainsKey("Persist"))
452452
{
453-
$environment = Register-Environment -EnvironmentName $outputVariable -EnvironmentSpecification $machineSpecification -WinRmProtocol "HTTPS" -Connection $connection -TaskContext $distributedTaskContext -TagsList $tagsList -Persist
453+
$environment = Register-Environment -EnvironmentName $outputVariable -EnvironmentSpecification $machineSpecification -WinRmProtocol "HTTPS" -Connection $connection -TaskContext $distributedTaskContext -TagsList $tagsList -Persist
454+
Write-Verbose "Completed Register-Environment for : $resourceGroupName, adding environment $outputVariable to output variables"
455+
Set-TaskVariable -Variable $outputVariable -Value $outputVariable
454456
}
455457
else
456458
{
457459
$environment = Register-Environment -EnvironmentName $outputVariable -EnvironmentSpecification $machineSpecification -WinRmProtocol "HTTPS" -Connection $connection -TaskContext $distributedTaskContext -TagsList $tagsList
458-
}
459-
Write-Verbose "Completed Register-Environment cmdlet call for resource group : $resourceGroupName"
460-
461-
Write-Verbose "Adding environment $outputVariable to output variables"
462-
Set-TaskVariable -Variable $outputVariable -Value $outputVariable
460+
Write-Verbose "Completed Register-Environment for : $resourceGroupName, converting environment as json and setting as output variable" -verbose
461+
$envStr = $environment.ToString() -replace "`n|`r"
462+
write-host "##vso[task.setvariable variable=$outputVariable;issecret=true;]$envStr"
463+
}
463464
Write-Verbose "Added the environment $outputVariable to output variable"
464465
}
465466

Tasks/DeployAzureResourceGroup/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 76
16+
"Patch": 77
1717
},
1818
"demands": [
1919
"azureps"
2020
],
21-
"minimumAgentVersion": "1.97.0",
21+
"minimumAgentVersion": "1.101.0",
2222
"groups": [
2323
{
2424
"name": "output",

Tasks/DeployAzureResourceGroup/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 76
16+
"Patch": 77
1717
},
1818
"demands": [
1919
"azureps"
2020
],
21-
"minimumAgentVersion": "1.97.0",
21+
"minimumAgentVersion": "1.101.0",
2222
"groups": [
2323
{
2424
"name": "output",

Tasks/PowerShellOnTargetMachines/PowerShellOnTargetMachines.ps1

Lines changed: 10 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ if ($enableDetailedLoggingString -ne "true")
6262
$enableDetailedLoggingString = "false"
6363
}
6464

65-
$isAgentVersion97 = ((gcm Register-Environment).Parameters.ContainsKey("Persist"));
66-
6765
# Telemetry
6866

6967
$telemetryCodes =
@@ -131,26 +129,12 @@ function Get-ResourceWinRmConfig
131129
$winrmPortToUse = ''
132130
$protocolToUse = ''
133131

134-
if(-not $isAgentVersion97)
135-
{
136-
Write-Verbose "Starting Get-Environment cmdlet call on environment name: $environmentName"
137-
$environment = Get-Environment -environmentName $environmentName -TaskContext $distributedTaskContext
138-
Write-Verbose "Completed Get-Environment cmdlet call on environment name: $environmentName"
139-
}
140-
141132
if($protocol -eq "HTTPS")
142133
{
143134
$protocolToUse = $useHttpsProtocolOption
144135

145136
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpsPortKeyName"
146-
if($isAgentVersion97)
147-
{
148-
$winrmPortToUse = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpsPortKeyName -ResourceId $resourceId
149-
}
150-
else
151-
{
152-
$winrmPortToUse = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceWinRMHttpsPortKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
153-
}
137+
$winrmPortToUse = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpsPortKeyName -ResourceId $resourceId
154138
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId (Name : $resourceName) and key: $resourceWinRMHttpsPortKeyName"
155139

156140
if([string]::IsNullOrWhiteSpace($winrmPortToUse))
@@ -164,14 +148,7 @@ function Get-ResourceWinRmConfig
164148
$protocolToUse = $useHttpProtocolOption
165149

166150
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpPortKeyName"
167-
if($isAgentVersion97)
168-
{
169-
$winrmPortToUse = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpPortKeyName -ResourceId $resourceId
170-
}
171-
else
172-
{
173-
$winrmPortToUse = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceWinRMHttpPortKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
174-
}
151+
$winrmPortToUse = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpPortKeyName -ResourceId $resourceId
175152
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpPortKeyName"
176153

177154
if([string]::IsNullOrWhiteSpace($winrmPortToUse))
@@ -186,29 +163,15 @@ function Get-ResourceWinRmConfig
186163
Write-Verbose "`t Environment is not standerd environment. Https port has higher precedence"
187164

188165
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpsPortKeyName"
189-
if($isAgentVersion97)
190-
{
191-
$winrmHttpsPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpsPortKeyName -ResourceId $resourceId
192-
}
193-
else
194-
{
195-
$winrmHttpsPort = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceWinRMHttpsPortKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
196-
}
166+
$winrmHttpsPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpsPortKeyName -ResourceId $resourceId
197167
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId (Name : $resourceName) and key: $resourceWinRMHttpsPortKeyName"
198168

199169
if ([string]::IsNullOrEmpty($winrmHttpsPort))
200170
{
201171
Write-Verbose "`t Resource: $resourceName does not have any winrm https port defined, checking for winrm http port"
202172

203173
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpPortKeyName"
204-
if($isAgentVersion97)
205-
{
206-
$winrmHttpPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpPortKeyName -ResourceId $resourceId
207-
}
208-
else
209-
{
210-
$winrmHttpPort = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceWinRMHttpPortKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
211-
}
174+
$winrmHttpPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpPortKeyName -ResourceId $resourceId
212175
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpPortKeyName"
213176

214177
if ([string]::IsNullOrEmpty($winrmHttpPort))
@@ -235,29 +198,15 @@ function Get-ResourceWinRmConfig
235198
Write-Verbose "`t Environment is standerd environment. Http port has higher precedence"
236199

237200
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpPortKeyName"
238-
if($isAgentVersion97)
239-
{
240-
$winrmHttpPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpPortKeyName -ResourceId $resourceId
241-
}
242-
else
243-
{
244-
$winrmHttpPort = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceWinRMHttpPortKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
245-
}
201+
$winrmHttpPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpPortKeyName -ResourceId $resourceId
246202
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpPortKeyName"
247203

248204
if ([string]::IsNullOrEmpty($winrmHttpPort))
249205
{
250206
Write-Verbose "`t Resource: $resourceName does not have any winrm http port defined, checking for winrm https port"
251207

252208
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpsPortKeyName"
253-
if($isAgentVersion97)
254-
{
255-
$winrmHttpsPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpsPortKeyName -ResourceId $resourceId
256-
}
257-
else
258-
{
259-
$winrmHttpsPort = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceWinRMHttpsPortKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
260-
}
209+
$winrmHttpsPort = Get-EnvironmentProperty -Environment $environment -Key $resourceWinRMHttpsPortKeyName -ResourceId $resourceId
261210
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceWinRMHttpsPortKeyName"
262211

263212
if ([string]::IsNullOrEmpty($winrmHttpsPort))
@@ -300,14 +249,7 @@ function Get-SkipCACheckOption
300249

301250
# get skipCACheck option from environment
302251
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with key: $skipCACheckKeyName"
303-
if($isAgentVersion97)
304-
{
305-
$skipCACheckBool = Get-EnvironmentProperty -Environment $environment -Key $skipCACheckKeyName
306-
}
307-
else
308-
{
309-
$skipCACheckBool = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $skipCACheckKeyName -TaskContext $distributedTaskContext
310-
}
252+
$skipCACheckBool = Get-EnvironmentProperty -Environment $environment -Key $skipCACheckKeyName
311253
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with key: $skipCACheckKeyName"
312254

313255
if ($skipCACheckBool -eq "true")
@@ -327,14 +269,7 @@ function Get-ResourceConnectionDetails
327269
$resourceId = $resource.Id
328270

329271
Write-Verbose "Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceFQDNKeyName"
330-
if($isAgentVersion97)
331-
{
332-
$fqdn = Get-EnvironmentProperty -Environment $environment -Key $resourceFQDNKeyName -ResourceId $resourceId
333-
}
334-
else
335-
{
336-
$fqdn = Get-EnvironmentProperty -EnvironmentName $environmentName -Key $resourceFQDNKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId
337-
}
272+
$fqdn = Get-EnvironmentProperty -Environment $environment -Key $resourceFQDNKeyName -ResourceId $resourceId
338273
Write-Verbose "Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceFQDNKeyName"
339274

340275
$winrmconfig = Get-ResourceWinRmConfig -resourceName $resourceName -resourceId $resourceId
@@ -376,14 +311,8 @@ try
376311
Write-Verbose "Completed Register-Environment cmdlet call for environment : $environmentName"
377312

378313
Write-Verbose "Starting Get-EnvironmentResources cmdlet call on environment name: $environmentName"
379-
if($isAgentVersion97)
380-
{
381-
$resources = Get-EnvironmentResources -Environment $environment
382-
}
383-
else
384-
{
385-
$resources = Get-EnvironmentResources -EnvironmentName $environmentName -TaskContext $distributedTaskContext
386-
}
314+
$resources = Get-EnvironmentResources -Environment $environment
315+
387316
if ($resources.Count -eq 0)
388317
{
389318
Write-TaskSpecificTelemetry "PREREQ_NoResources"

Tasks/PowerShellOnTargetMachines/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 33
16+
"Patch": 34
1717
},
1818
"minimumAgentVersion": "1.101.0",
1919
"groups": [

Tasks/PowerShellOnTargetMachines/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 33
16+
"Patch": 34
1717
},
1818
"minimumAgentVersion": "1.101.0",
1919
"groups": [

Tasks/WindowsMachineFileCopy/WindowsMachineFileCopy.ps1

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ $resourceFQDNKeyName = Get-ResourceFQDNTagKey
3838

3939
$envOperationStatus = 'Passed'
4040

41-
$isAgentVersion97 = ((gcm Register-Environment).Parameters.ContainsKey("Persist"));
42-
4341
function ThrowError
4442
{
4543
param([string]$errorMessage)
@@ -60,14 +58,7 @@ function Get-ResourceConnectionDetails
6058
$resourceId = $resource.Id
6159

6260
Write-Verbose "`t`t Starting Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceFQDNKeyName"
63-
if($isAgentVersion97)
64-
{
65-
$fqdn = Get-EnvironmentProperty -Environment $environment -Key $resourceFQDNKeyName -ResourceId $resourceId -ErrorAction Stop
66-
}
67-
else
68-
{
69-
$fqdn = Get-EnvironmentProperty -EnvironmentName $envName -Key $resourceFQDNKeyName -TaskContext $distributedTaskContext -ResourceId $resourceId -ErrorAction Stop
70-
}
61+
$fqdn = Get-EnvironmentProperty -Environment $environment -Key $resourceFQDNKeyName -ResourceId $resourceId -ErrorAction Stop
7162
Write-Verbose "`t`t Completed Get-EnvironmentProperty cmdlet call on environment name: $environmentName with resource id: $resourceId(Name : $resourceName) and key: $resourceFQDNKeyName"
7263

7364
Write-Verbose "`t`t Resource fqdn - $fqdn"
@@ -163,14 +154,7 @@ else
163154
$fetchedEnvironmentName = $environment.Name
164155

165156
Write-Verbose "Starting Get-EnvironmentResources cmdlet call on environment name: $fetchedEnvironmentName"
166-
if($isAgentVersion97)
167-
{
168-
$resources = Get-EnvironmentResources -Environment $environment
169-
}
170-
else
171-
{
172-
$resources = Get-EnvironmentResources -EnvironmentName $fetchedEnvironmentName -TaskContext $distributedTaskContext
173-
}
157+
$resources = Get-EnvironmentResources -Environment $environment
174158
Write-Verbose "Completed Get-EnvironmentResources cmdlet call for environment name: $fetchedEnvironmentName"
175159

176160
if ($resources.Count -eq 0)

Tasks/WindowsMachineFileCopy/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 28
16+
"Patch": 29
1717
},
1818
"minimumAgentVersion": "1.101.0",
1919
"groups": [

Tasks/WindowsMachineFileCopy/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 28
16+
"Patch": 29
1717
},
1818
"minimumAgentVersion": "1.101.0",
1919
"groups": [

0 commit comments

Comments
 (0)