在devops管道中从Prowershell访问Azure Cli [英] Accessing Azure Cli from Prowershell in devops pipeline

查看:69
本文介绍了在devops管道中从Prowershell访问Azure Cli的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从事需要通过Powershell访问kubernetes的管道作业. 唯一的问题是我需要登录Az cli.对于测试,我使用我的个人凭据,显然不是一个好的最终选择.是否可以替代使用Azure cli登录的其他任何选项?

I'm currently working on a pipeline job that requires kubernetes access through powershell. The only issue is that I need to sign in for Az cli. For testing I'm using my personal credentials, clearly not a good definitive option. Are there any other options for Azure cli login that could be used instead?

推荐答案

我猜您正在使用托管代理,因此,您需要在托管代理上配置kube.config.

I'm guessing you are working with hosted agents, therefore, you need to configure kube.config on the hosted agent.

为此,请运行az aks get-credentials --name $(CLUSTER_NAME) --resource-group $(RESOURCE_GROUP_NAME).最简单的方法是使用Azure CLI任务.请注意,此任务需要从Azure DevOps到Azure的授权. 可以找到更多信息

in order to do that, run az aks get-credentials --name $(CLUSTER_NAME) --resource-group $(RESOURCE_GROUP_NAME). The easiest way is to use Azure CLI task. Be aware that this task required authorization from Azure DevOps to Azure. More info can be found here.

如果您是订阅的所有者,请选择您的订阅,然后单击Authorize.

In case you are the subscription owner- select your subscription and click on Authorize.

在托管代理上配置kube.config后,可以运行所需的任何kubectl命令(使用Powershell \ Bash \ CMD).

When the kube.config configured on the hosted agent, you can run any kubectl command you wish (Using Powershell\Bash\CMD).

这篇关于在devops管道中从Prowershell访问Azure Cli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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