You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If using Azure Pipelines, provide the account name, team project name, build definition name/build number: Microsoft, redacted, redacted, redacted (internal)
Agent - Hosted or Private:
If using Hosted agent, provide agent queue name: Not entirely sure of policy regarding publicly sharing agent queue names
If using private agent, provide the OS of the machine running the agent and the agent version: Windows Server 2019 Datacenter 17763.1637, VSTS Agent 2.179, AzureUSGovernment
Issue Description
We have a system in our Azure Pipelines (YAML) deployment that conditionally splits powershell tasks that reference Azure resources between AzureCloud and USGov, because we are having issues using an AzurePowerShell task when:
AzureCloud has a service principal-based service connection to a microsoft-hosted agent
USGov has a managed identity-on-VM-agent-based service connection.
020-12-14T17:43:25.4443556Z ##[command]Connect-AzAccount -Identity @processScope
2020-12-14T17:43:26.8625685Z ##[command] Set-AzContext -SubscriptionId *** -TenantId ***
2020-12-14T17:43:26.9393026Z ##[debug]Leaving Initialize-AzModule.
2020-12-14T17:43:26.9623941Z ##[error]Initializing Az module failed: For troubleshooting, refer: https://aka.ms/azurepowershelltroubleshooting
2020-12-14T17:43:26.9632364Z ##[debug]Processed: ##vso[task.logissue type=error]Initializing Az module failed: For troubleshooting, refer: https://aka.ms/azurepowershelltroubleshooting
2020-12-14T17:43:26.9633671Z ##[debug]Caught exception from task script.
2020-12-14T17:43:26.9641810Z ##[debug]Error record:
2020-12-14T17:43:27.0517810Z ##[debug]Set-AzContext : Please provide a valid tenant or a valid subscription.
2020-12-14T17:43:27.0530114Z ##[debug]At C:\agent\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_\InitializeAzModuleFunctions.ps1:190 char:13
2020-12-14T17:43:27.0543734Z ##[debug]+ $null = Set-AzContext -SubscriptionId $SubscriptionId @additional
2020-12-14T17:43:27.0587035Z ##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-12-14T17:43:27.0614976Z ##[debug] + CategoryInfo : CloseError: (:) [Set-AzContext], ArgumentException
2020-12-14T17:43:27.0631319Z ##[debug] + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.SetAzureRMContextCommand
2020-12-14T17:43:27.0651161Z ##[debug]
As a result, we and others in related teams are using conditional branches and split stages where an environment using AzureUSGovernment executes a similar task, but with PowerShell@2 with Connect-AzAccount:
cutecycle
changed the title
Account Connection failure when using AzurePowerShell@4, AzurePowerShell@5 with Sovereign Environments
Account Connection failure on self-hosted agent when using AzurePowerShell@4, AzurePowerShell@5 with Sovereign Environment via Managed Identity
Jan 5, 2021
Required Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature? Bug
Type: Bug
Enter Task Name: AzurePowerShell
list here (V# not needed): 4,5
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks
Environment
Server - Azure Pipelines or TFS on-premises?
If using TFS on-premises, provide the version:
If using Azure Pipelines, provide the account name, team project name, build definition name/build number: Microsoft, redacted, redacted, redacted (internal)
Agent - Hosted or Private:
If using Hosted agent, provide agent queue name: Not entirely sure of policy regarding publicly sharing agent queue names
If using private agent, provide the OS of the machine running the agent and the agent version: Windows Server 2019 Datacenter 17763.1637, VSTS Agent 2.179, AzureUSGovernment
Issue Description
We have a system in our Azure Pipelines (YAML) deployment that conditionally splits powershell tasks that reference Azure resources between
AzureCloud
and USGov, because we are having issues using anAzurePowerShell
task when:work with the USGov service connection,
but the
AzurePowerShell@5
task doesn't.It does seem to correctly realize that the Service Connection is a USGov one based on
$endpointObject.environment
:But eventually fails to login:
As a result, we and others in related teams are using conditional branches and split stages where an environment using
AzureUSGovernment
executes a similar task, but withPowerShell@2
withConnect-AzAccount
:AzureCloud:
AzureUSGovernment:
Troubleshooting
Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting
Error logs
The text was updated successfully, but these errors were encountered: