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

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

问题描述

每当将提交推送到主服务器时,我似乎都没有授权在Azure DevOps中授权对我的Azure订阅的访问来运行生成.我不断收到以下错误:

此外,当我单击授权资源时,它表示授权已成功,但是下次我运行管道时,会得到相同的确切错误.我已在项目设置"中验证->我已与订阅建立有效连接的服务连接.

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

解决方案

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

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

1,检查您的Yaml管道.

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

您可以查看

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

1,转到项目设置->管道下的服务连接->新服务连接->选择 Azure资源管理器->下一个

2,然后选择身份验证方法.如果您的azure devops是

创建天蓝色的订阅服务连接后.通过指定服务连接名称,可以在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天全站免登陆