M. Carlo Bramini
M. Carlo Bramini

Reputation: 2532

Accessing Azure Cli from Prowershell in devops pipeline

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? enter image description here

Upvotes: 1

Views: 1019

Answers (1)

Amit Baranes
Amit Baranes

Reputation: 8152

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

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.

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

enter image description here

enter image description here

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

enter image description here

Upvotes: 1

Related Questions