Azure DevOps:服务连接未被识别 [英] Azure DevOps: Service connection is not being recognized

查看:20
本文介绍了Azure DevOps:服务连接未被识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在 Azure DevOps 中授权访问我的 Azure 订阅,以便在将提交推送到 master 时运行构建.我不断收到以下错误:

另外,当我单击 Authorize resources 时,它表示授权成功,但下次我运行管道时,我得到了同样的错误.我在项目设置中验证了 ->我与订阅有活动连接的服务连接.

我该如何解决这个问题?当我转到 Azure Functions 中的部署中心并在那里建立连接时,它会创建一个基于任务的管道,但我想使用 yaml.

解决方案

以上表示你在azure函数部署任务中指定的azureSubscription不存在,或者你没有权限.

如果服务连接已经正确设置,但您仍然遇到上述错误.您可以按照以下步骤解决问题.

1,检查您的 yaml 管道.

Azure 订阅在编译时进行验证.如果您使用变量来引用 azure 订阅 yaml 管道.您需要确保可以在编译时检索该变量.

您可以查看

如果未设置 Azure 订阅服务连接.您需要创建 azure 资源管理器类型的服务连接以连接到您的 azure 订阅.请参阅以下步骤:

1、进入项目设置-->Pipelines下的Service Connections-->新建服务连接-->选择 Azure 资源管理器-->下一个

2、然后选择认证方式.如果您的 azure devops 是

在您的 Azure 订阅服务连接创建之后.您可以通过指定服务连接名称在 yaml 管道任务中使用它.见下例:

- 任务:AzureFunctionApp@1displayName:Azure 函数应用部署输入:azureSubscription: myAzureSubscription

注意:您需要为上述服务主体添加正确的角色分配,以使服务主体能够部署到您的Azure资源.

I can't seem to authorize access to my Azure subscription in Azure DevOps to run a build whenever a commit is pushed to master. I keep getting the below error:

Also, when I click Authorize resources, it says the authorization was successful, but the next time I run the pipeline, I get the same exact error. I verified in Project settings -> Service connections that I have an active connection to the subscription.

How can I get around this issue? When I go to Deployment Center in Azure Functions and wire up the connection there, it creates a task-based pipeline, but I want to use yaml.

解决方案

The above indicates the azureSubscription you specified in your azure function deployment task doesnot exist, or you didnot have the permission.

If the service connection is already correctly setup, but you still encounter above error. You can follow below to troubleshoot the issue.

1, Check your yaml pipeline.

The azure subscription is validated at compile time. If you use variables to reference the azure subscription yaml pipeline. You need to make sure the variable can be retrieved at compile time.

You can check out this thread.

2, Check the service connection security setting.

Go to project settings-->Service Connections under Pipelines--> Select your azure service connection --> More settings(3 dots)-->Security-->Try adding your pipeline to the Pipeline permissions list.

If the azure subscription service connection is not set up. You need to create an service connection of azure Resource Manager type to connect to your azure subscription. See below steps:

1, Go to project settings-->Service Connections under Pipelines--> New Service connection-->Select Azure Resource Manager--> Next

2, Then select the Authentication method. If your azure devops is connected to AAD. You can select Service principal (automatic) as Authentication method. This will automatically create a service principal in your Azure AD.

3, If you want to create new service principal. You can select Service principal (manual). See below document to create service principal in Azure

Use the portal to create an Azure Active Directory application and a service principal that can access resources

Use Azure PowerShell to create an Azure service principal with a certificate

Then enter the related information in the service connection configuration page.

After the your azure subscription service connection is created. You can use it in your yaml pipeline task by specify the service connection name. See below example:

- task: AzureFunctionApp@1
  displayName: Azure Function App Deploy
  inputs:
    azureSubscription: myAzureSubscription  

Note: You need to add the correct role assignment for above service principal to enable the service principal to deploy to your azure resources.

这篇关于Azure DevOps:服务连接未被识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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