错误:请求的资源需要用户身份验证:在AzureCLI任务生成管道中 [英] ERROR: The requested resource requires user authentication: in AzureCLI task build pipeline

查看:9
本文介绍了错误:请求的资源需要用户身份验证:在AzureCLI任务生成管道中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从azureCLI任务触发Azure管道构建

任务:

- task: AzureCLI@2
  inputs:
    azureSubscription: 'Free Trial(My subscription)'
    scriptType: 'pscore'
    scriptLocation: 'inlineScript'
    inlineScript: |
      az --version
      echo "Running : az account show"
      az account show
      #export AZURE_DEVOPS_EXT_PAT='mypat'
      $env:AZURE_DEVOPS_EXT_PAT='mypat'
      az pipelines create --name newPipeline --org https://dev.azure.com/AbiNilOrg/ --project azure-devops-kubernetes-terraform --branch master

出现错误的输出:

Running : az account show
{
  "environmentName": "AzureCloud",
  "homeTenantId": "***",
  "id": "73c1af29-384c-4574-bd88-92d7bb392cfc",
  "isDefault": true,
  "managedByTenants": [],
  "name": "Free Trial",
  "state": "Enabled",
  "tenantId": "***",
  "user": {
    "name": "***",
    "type": "servicePrincipal"
  }
}
WARNING: This command is in preview and under development. Reference and support 
levels: https://aka.ms/CLI_refstatus
ERROR: The requested resource requires user authentication: 
https://dev.azure.com/AbiNilOrg/azure-devops-kubernetes- 
terraform/_apis/serviceendpoint/endpoints
##[error]Script failed with exit code: 1

我了解到Azure无法形成正确的URI来命中睡觉点

ERROR: The requested resource requires user authentication: 
https://dev.azure.com/AbiNilOrg/azure-devops-kubernetes- 
terraform/_apis/serviceendpoint/endpoints

URI的后缀serviceEndpoint不正确。

ADO的朋友们,如果您对此有任何想法,请帮助我们!

提前感谢! 尼洛特帕尔

推荐答案

设置env:AZURE_DEVOPS_EXT_PAT仍需要调用登录:

az devops login --organization https://dev.azure.com/contoso

因为:

如果您已经以交互方式或使用用户名和密码使用az login登录,则不必提供令牌,因为az devops命令现在支持通过az login登录。但是,不支持通过az登录进行服务主体登录,在这种情况下需要PAT令牌。

这里是通过服务主体进行场景登录的任务,您在帐户上也可以看到:

  "user": {
    "name": "***",
    "type": "servicePrincipal"
  }

有关详细信息,请查看文档here

这篇关于错误:请求的资源需要用户身份验证:在AzureCLI任务生成管道中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆