I am trying to fetch Azure Artifacts through Service Principal in PowerShell but not able to do it. Reproduction step:
az login --service-principal --username "" -p="" --tenant "" Above command works fine and returns the following output: [ { "cloudName": "", "homeTenantId": "", "id": "", "isDefault": true, "managedByTenants": [], "name": "Microsoft Azure Enterprise", "state": "Enabled", "tenantId": "", "user": { "name": "", "type": "servicePrincipal" } } ] Then I ran the following command to download the artifacts:
az artifacts universal download --organization "" --project "" --scope project --feed "" --name "" --version "" --path .
Error: python.exe : WARNING: Could not retrieve credential from local cache for service principal under tenant . Trying credential under tenant , assuming that is an app credential. At C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.ps1:2 char:1
- & "$PSScriptRoot..\python.exe" -IBm azure.cli $args
-
+ CategoryInfo : NotSpecified: (WARNING: Could ...app credential.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
WARNING: Could not retrieve credential from local cache for service principal under tenant . Trying credential under tenant , assuming that is an app credential. ERROR: Failed to update Universal Packages tooling. Before you can run Azure DevOps commands, you need to run the login command(az login if using AAD/MSA identity else az devops login if using PAT token) to setup credentials. Please see https://aka.ms/azure-devops-cli-auth for more information.
I am able to download the artifacts when I simply run az login, then pass the authentication through browser and then run the az artifact download command. But I want to automate this process through code so I need to login programmatically.
Please let me know what can I do? I have already spent a lot of days for this issue. Thanks