Accessing Azure Cli from Prowershell in devops pipeline - kubernetes

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?

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.
When the kube.config configured on the hosted agent, you can run any kubectl command you wish (Using Powershell\Bash\CMD).

Related

Getting Azure Devops NPM feed Authentication Token from CLI

I am using azure devops to host an authenticated NPM feed. I would like to generate a token to access that feed using the CLI. The instructions on azure devops involve going through the web interface to generate a personal access token (PAT), then base64-ing that token, and adding it to the .npmrc. If I do that, I'm able to run npm install against that feed without issue.
In the CLI, I've tried using az account get-access-token, grabbing that token, and encoding it. But that seems to fail, and I guess that makes sense because it is a token for azure itself, not azure devops.
Does anyone have any guidance on how this could be done? Am I stuck doing it manually?
az account get-access-token get a token for utilities to access Azure.
It's not Azure DevOps.
We also have an az devops CLI command. But we could not be able to get/create a token through this. Neither does Rest API.
You'll have to manually create the PAT token from web interface in your Azure DevOps Organization.

Can Azure Devops pipelines update Azure App Configuration

Had a quick google, and there appears to be nothing out there.
Can an Azure Pipeline update Azure App Configuration? Or would it make sense to be builds and deployment/run-time config away from each other
The Azure App Configuration Push task works pretty well now :
https://learn.microsoft.com/en-us/azure/azure-app-configuration/push-kv-devops-pipeline
Probably the simplest solution to get this working is by using Azure CLI which you can integrate into your pipelines using the Azure CLI task.
To update, use the az appconfig kv set command.
Set a key using an App Configuration name and label
az appconfig kv set -n {name} --key {key1} --label {label} --value {value1} --content-type {text} --tags {tag1,tag2}
Can an Azure Pipeline update Azure App Configuration?
Apart from the az appconfig kv set in rickvdbosch's answer, you can also consider using Azure Resource Manager which can also be used to manage app settings. See similar hint here.
You can use Override template parameters option in Azure Resource Group Deployment task to update the app configurations in build/release pipeline.

How to use Azure DevOps Extension for Azure CLI with Azure DevOps Server?

The Azure CLI with the Azure DevOps extension has replaced the VSTS CLI. But I can't find any sample on how to connect to Team Foundation Server (TFS) or Azure DevOps Server using Azure CLI with Azure DevOps extension.
I tried to create a PAT on my Azure DevOps Server with all scope permission. Then I use the following command to login:
az devops login --organization https://vm-dev-cgudevops/DefaultCollection --verbose
Here is what I've got:
C:\>az devops login --organization https://vm-dev-cgudevops/DefaultCollection --verbose
Token:
Creating connection with personal access token.
Failed to authenticate using the supplied token.
Suppress exception There are no active accounts.
Suppress exception Please run 'az login' to setup account.
command ran in 25.138 seconds.
The token can't be wrong. I don't know what's going on.
At present Azure DevOps CLI is not supported for Azure DevOps server. This is fundamentally due to API versioning as Azure DevOps Server runs on a particular version but the CLI client consistently updates to the latest version. Therefore, ideally if you are using the latest version of Azure DevOps Server, then the CLI should work for you as both are using the same API versions.
Have a look at the docs available at - https://learn.microsoft.com/en-us/azure/devops/cli/index?view=azure-devops
Azure Cli support login your private TFS currently, see: https://learn.microsoft.com/en-us/azure/devops/cli/log-in-via-pat?view=azure-devops&tabs=windows
Create PAT
Login with PAT, eg. cat PAT.txt|az devops login --organization http://your_tfs_url
There is an extension in Azure DevOps that let's you mange the Azure DevOps from Azure CLI.
As mentioned in the extension you have to :
Install the Azure CLI. You must have at least v2.0.49, which you can
verify with az --version command.
Add the Azure DevOps Extension az extension add --name azure-devops
Run the az login command.
You can also find a sample for it here.
Read this article if you need more information about how to get started with it.
Add /tfs/DefaultCollection to URL. That did the trick for me.

How do I publish to an On-Prem computer using Azure Pipelines?

I want to use Azure DevOps to deploy to my client's on-prem computer.
I have been looking at docs on build and release agents At first I thought that maybe it was a "self-hosted agent" but after reading further I thought it might be deployment groups. that I need. However deployment groups seem to be about VMs
in Azure DevOps portal ( dev.azure.com)
Organization Settings > Agent pools > Default
download the agent
make sure to use powershell not powershell ise

Enable/disable Azure Logic App using CLI

Is it possible to enable/disable an Azure Logic App using the CLI? I didn't find anything about it in the documentation.
There's a way to do it via the REST API, which requires creating an access token. However, since I'm running from my shell or from VSTS (which has a az CLI task), I'm already authorized there so I'd like to simplify this process using the CLI.
You should be able to do it using the following command
az resource invoke-action --action disable --name 'YOURLOGICAPP' -g 'YOURRESOURCEGROUP' --resource-type 'Microsoft.Logic/workflows'