Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: AzureCLI@2 az login fails when using certificate for authentication starting from version 2.67.0 of Azure CLI #20672

Open
jan-msc opened this issue Nov 19, 2024 · 10 comments

Comments

@jan-msc
Copy link

jan-msc commented Nov 19, 2024

Starting from version 2.67.0, for az login, --password no longer accepts service principal certificate. Use --certificate to pass a service principal certificate.
AzureCLI@2 does not use the --certificate parameter to pass the service principal certificate resulting in:
ERROR: AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '***'. The error may be caused by passing a service principal certificate with --password. Please note that --password no longer accepts a service principal certificate. To pass a service principal certificate, use --certificate instead.

@NakagawaMakoto
Copy link

I am experiencing the same issue. Is there any way to downgrade azure cli to prior version?

@jan-msc
Copy link
Author

jan-msc commented Nov 25, 2024

@NakagawaMakoto : Azure CLI has no downgrade functionality but you can uninstall it and install the desired version (2.66.0) instead.

@NakagawaMakoto
Copy link

Yes, of course, it is me who is responsible for the version of azcli on the pipeline agent's host. I should have known better. Thank you for reminding me of the fact.

@RichieBzzzt
Copy link

To work around this issue we added this step to our builds. Would love to see the issue fixed though!

    apt-get remove -y azure-cli
    apt-get install -y azure-cli=2.66.0-1~focal```

@mhever
Copy link

mhever commented Nov 27, 2024

This is breaking user pipelines on our side, this should be fixed asap.

@v-schhabra v-schhabra added the Area:RM RM task team label Nov 28, 2024
@vi7us
Copy link

vi7us commented Nov 29, 2024

As a workaround, adding this task should help on windows host

 - powershell: |
    wmic product where "name='Microsoft Azure CLI (64-bit)'" call uninstall /nointeractive
    Invoke-WebRequest -Uri https://azcliprod.blob.core.windows.net/msi/azure-cli-2.66.0-x64.msi -OutFile .\AzureCLI.msi; 
    Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet';
  displayName: Downgrade azure CLI

@robkendrick
Copy link

As a workaround, adding this task should help on windows host

Thanks for this--I wasn't having much luck with the msiexec.exe /x uninstaller! Unfortunately, it takes the Hosted Agents anywhere from six to fourteen minutes to complete the uninstall.

In the interim, I've added Federated Credentials to the App Registration in Entra ID, then associated that with a new Service Connection in AzDO, and that works with no issues--pipelines are back to being speedy. The great part about this method (thus far) is that because it's the same AppID it uses the same Service Principal (Enterprise Apps in EID), so you don't have to go update the RBAC for every resource.

For those who haven't done this before, here's a quick rundown of how to do it:

  1. Go to your Service Connections under Project Settings (can also just use the standard URI: https://dev.azure.com/<orgName>/<projectName | projectID>/_settings/adminservices)
  2. Click [ New Service Connection ] -> Azure Resource Manager -> [ Next ] -> Workload Identity federation (manual) -> [ Next ].
  3. Give the Service Connection a name that is distinctive from the existing version of the service principal.
    • I would advise naming it something that indicates they're related (e.g.: original is "ServiceConnection-Dev-Certificate", make this one "ServiceConnection-Dev-Federated"). Tick/enable "Grant access permission to all pipelines" only if needed, then click [ Next ].
  4. Leave that tab as-is because you'll need the provided Issuer and Subject Identifier values. Open a new tab, then go to AAD/EID.
  5. Go to your App Registration for the existing Service Connection (or a new one if you decide to go that route), then click on the Manage -> Certificates & secrets Blade.
  6. Click Federated Credentials, then + Add credential.Image
  7. Enter/Select the following:
    a. Federated credential scenario: Other
    b. Issuer: Enter the Issuer from the AzDO Service Connection in the previous tab.
    c. Subject Identifier: Enter this value from the AzDO Service Connection.
    d. Give the credential a name.
    e. Click [ Add ].
  8. Click the Overview blade on the left and then copy/save/notate the "Application (client) ID" for this App.
  9. Go back to the AzDO tab and finish setting up the Service Connection--remaining instructions assume a scope of "Subscription."
    a. Service Principal ID is the AppID copied from Step 9.
    b. Subscription ID and Name can be found easily on the Subscriptions blade.
    c. Tenant ID can be quickly pulled from the directory listing.
  10. Click [ Verify and Save ].
  11. Update your pipelines with the new Service Connection name and test.

@KKing299
Copy link

@robkendrick - What you said is partially a workaround. It doesn't work out for MSPs since one app registration can only have 20/30 federated credential. Whenever you create a service connection it will take up one federated credential. Let's say if someone wants to manage multiple tenants then it wouldn't work because of restriction on the number of federated credential an app registration can have.
@v-schhabra Does MS have any updates? This needs to be fixed ASAP! This is breaking production setup

@v-schhabra
Copy link
Contributor

v-schhabra commented Dec 11, 2024

Hi @KKing299
The issue has been fixed in this PR #20698
#20701
Please let us know if you are having any issues.

@v-schhabra
Copy link
Contributor

Hi @KKing299
please share the latest updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants