Skip to content

Commit 599eca1

Browse files
authored
Add Get-Command to fix missing Install-Module in AzurePowerShell (#20621)
* Add dummy command to fix missing Install-Module * Use SC id rather than dummy text * Use directly Get-Command to fix the issue
1 parent 615e37a commit 599eca1

File tree

12 files changed

+109
-80
lines changed

12 files changed

+109
-80
lines changed

Tasks/AzurePowerShellV5/InitializeAz.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ elseif ($endpointObject.scheme -eq 'WorkloadIdentityFederation') {
121121
$env:AZURESUBSCRIPTION_SERVICE_CONNECTION_ID = $serviceConnectionId
122122
$env:AZURESUBSCRIPTION_CLIENT_ID = $endpointObject.servicePrincipalClientID
123123
$env:AZURESUBSCRIPTION_TENANT_ID = $endpointObject.tenantId
124+
125+
if (![System.Convert]::ToBoolean($env:DISABLE_INSTALL_MODULE_FIX)) {
126+
# This is a workaround for the issue where Clear-AzContext removes Install-Module command from the session
127+
$null = Get-Command "Install-Module" -ErrorAction SilentlyContinue
128+
}
124129
}
125130
else {
126131
# Provide an additional, custom, credentials-related error message. Will handle localization later

Tasks/AzurePowerShellV5/package-lock.json

Lines changed: 39 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/AzurePowerShellV5/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 5,
2020
"Minor": 248,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "Added support for Az Module and cross platform agents.",
2424
"groups": [

Tasks/AzurePowerShellV5/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 5,
2020
"Minor": 248,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"groups": [
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|5.248.0
2-
Node20_229_2|5.248.1
1+
Default|5.248.2
2+
Node20_229_2|5.248.3

_generated/AzurePowerShellV5/InitializeAz.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ elseif ($endpointObject.scheme -eq 'WorkloadIdentityFederation') {
121121
$env:AZURESUBSCRIPTION_SERVICE_CONNECTION_ID = $serviceConnectionId
122122
$env:AZURESUBSCRIPTION_CLIENT_ID = $endpointObject.servicePrincipalClientID
123123
$env:AZURESUBSCRIPTION_TENANT_ID = $endpointObject.tenantId
124+
125+
if (![System.Convert]::ToBoolean($env:DISABLE_INSTALL_MODULE_FIX)) {
126+
# This is a workaround for the issue where Clear-AzContext removes Install-Module command from the session
127+
$null = Get-Command "Install-Module" -ErrorAction SilentlyContinue
128+
}
124129
}
125130
else {
126131
# Provide an additional, custom, credentials-related error message. Will handle localization later

_generated/AzurePowerShellV5/package-lock.json

Lines changed: 39 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_generated/AzurePowerShellV5/task.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 5,
2020
"Minor": 248,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "Added support for Az Module and cross platform agents.",
2424
"groups": [
@@ -204,7 +204,7 @@
204204
"PS_ExitCode": "PowerShell exited with code '{0}'."
205205
},
206206
"_buildConfigMapping": {
207-
"Default": "5.248.0",
208-
"Node20_229_2": "5.248.1"
207+
"Default": "5.248.2",
208+
"Node20_229_2": "5.248.3"
209209
}
210210
}

_generated/AzurePowerShellV5/task.loc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 5,
2020
"Minor": 248,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"groups": [
@@ -204,7 +204,7 @@
204204
"PS_ExitCode": "ms-resource:loc.messages.PS_ExitCode"
205205
},
206206
"_buildConfigMapping": {
207-
"Default": "5.248.0",
208-
"Node20_229_2": "5.248.1"
207+
"Default": "5.248.2",
208+
"Node20_229_2": "5.248.3"
209209
}
210210
}

_generated/AzurePowerShellV5_Node20/InitializeAz.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ elseif ($endpointObject.scheme -eq 'WorkloadIdentityFederation') {
121121
$env:AZURESUBSCRIPTION_SERVICE_CONNECTION_ID = $serviceConnectionId
122122
$env:AZURESUBSCRIPTION_CLIENT_ID = $endpointObject.servicePrincipalClientID
123123
$env:AZURESUBSCRIPTION_TENANT_ID = $endpointObject.tenantId
124+
125+
if (![System.Convert]::ToBoolean($env:DISABLE_INSTALL_MODULE_FIX)) {
126+
# This is a workaround for the issue where Clear-AzContext removes Install-Module command from the session
127+
$null = Get-Command "Install-Module" -ErrorAction SilentlyContinue
128+
}
124129
}
125130
else {
126131
# Provide an additional, custom, credentials-related error message. Will handle localization later

0 commit comments

Comments
 (0)