question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzurePowerShellV5/InitializeAz.ps1 is missing support for "$endpointObject.authenticationType -ieq 'SPNCertificate'"

See original GitHub issue

Note

Issues in this repo are for tracking bugs, feature requests and questions for the tasks in this repo

For a list:
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

If you have an issue or request for the Azure Pipelines service, use developer community instead:

https://developercommunity.visualstudio.com/spaces/21/index.html )

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: here
AzurePowerShell@4 AzurePowerShell@5

list here (V# not needed):
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzurePowerShellV4/InitializeAz.ps1 https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzurePowerShellV5/InitializeAz.ps1

Environment

  • Server - Azure Pipelines

  • Agent - Hosted

Issue Description

For service endpoints we are using "authorization": {"scheme": "ServicePrincipal" and "authenticationType": "spnCertificate". When using AzurePowerShell@4 or AzurePowerShell@5 on anything other then windows-latest it seems support is missing for this authenticationtype, since it throws "Only SPN credential auth scheme is supported for non windows agent.". Looking at InitializeAz.ps1 it only seems to try SPNKey;

  try {
        if ($endpointObject.authenticationType -ieq 'SPNKey') {

Task logs

2020-07-29T22:55:24.8405693Z ##[section]Starting: AzurePowerShell 2020-07-29T22:55:24.8414947Z ============================================================================== 2020-07-29T22:55:24.8415311Z Task : Azure PowerShell 2020-07-29T22:55:24.8415623Z Description : Run a PowerShell script within an Azure environment 2020-07-29T22:55:24.8415914Z Version : 4.173.1 2020-07-29T22:55:24.8416177Z Author : Microsoft Corporation 2020-07-29T22:55:24.8416500Z Help : https://aka.ms/azurepowershelltroubleshooting 2020-07-29T22:55:24.8416840Z ============================================================================== 2020-07-29T22:55:25.0002949Z ## Validating Inputs 2020-07-29T22:55:25.0068398Z ## Validating Inputs Complete 2020-07-29T22:55:25.0068607Z ## Initializing Az module 2020-07-29T22:55:25.0080295Z Generating script. 2020-07-29T22:55:25.0094224Z ## Az module initialization Complete 2020-07-29T22:55:25.0094776Z ## Beginning Script Execution 2020-07-29T22:55:25.0114361Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/home/vsts/work/_temp/8af16c39-ee29-44b6-8743-ee2da781b177.ps1' 2020-07-29T22:55:25.6483461Z ##[command]Import-Module -Name /usr/share/az_4.3.0/Az.Accounts/1.9.1/Az.Accounts.psd1 -Global 2020-07-29T22:55:26.0522176Z ##[command]Clear-AzContext -Scope Process 2020-07-29T22:55:26.9380706Z ##[command]Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue 2020-07-29T22:55:27.5543805Z Exception is : Only SPN credential auth scheme is supported for non windows agent. 2020-07-29T22:55:27.6778213Z OperationStopped: /home/vsts/work/_tasks/AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62/4.173.1/InitializeAz.ps1:91 2020-07-29T22:55:27.6779895Z Line | 2020-07-29T22:55:27.6780952Z  91 |  throw (New-Object System.Exception("There was an error with t … 2020-07-29T22:55:27.6782082Z  |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2020-07-29T22:55:27.6783134Z  | There was an error with the service principal used for the 2020-07-29T22:55:27.6784199Z  | deployment. 2020-07-29T22:55:27.6785072Z  2020-07-29T22:55:27.6942396Z ##[error]PowerShell exited with code '1'. 2020-07-29T22:55:27.6951601Z ## Script Execution Complete 2020-07-29T22:55:27.6954308Z ##[section]Finishing: AzurePowerShell

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Error logs

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
ransagycommented, Dec 23, 2021

Has anyone looked at this issue at any point? Not being able to run any PSCore task in Azure on non-windows machines is quite a limit.

The only workaround i found is creating a new Service Connection using the “Azure RM > Service Principal (Manual) > Service Principal Key” configuration, which supposedly excludes certs. Maybe the automatic one uses those and thus fails as mentioned here.

1reaction
pardhasaradhireddycommented, Mar 17, 2021

any progress with this? Still i am facing the same issue for linux machine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found