Mori
Mori

Reputation: 2574

Using Azure-Cli to deploy an azure function to azure from Jenkins

I have created a docker container and generated final artifact of my azure function app code. Azure Cli is already installed in the container. Is it possible to deploy to Azure using Azure Cli and pass the credentials along?

I tried the following command (example credentials):

az functionapp deployment user set --user-name "MY_USER" --password "MY_PASS" --subscription "MY_SUBSCRIPTION"

But it results in the following error:

Subscription 'MY_SUBSCRIPTION' not recognized. ValidationError: Please run 'az login' to setup account.

If I login (which requires entering a pass code to a browser), then the command above seems to be working.

This is going to be part of CI/CD and manual login is not a solution. Any ideas?

Upvotes: 1

Views: 1141

Answers (2)

krishg
krishg

Reputation: 6508

You would need to use a service principle to authenticate. But since you mentioned you are using Jenkins, fortunately there are rich set of plugins available for different Azure resources which can handle the authentication for you if you setup in your Jenkins dashboard. For example, in this case you are using az cli for which you can install https://plugins.jenkins.io/azure-cli/

Upvotes: 1

Pedro Perez
Pedro Perez

Reputation: 932

Yes, you need to be authenticated. Here you have several authentication options: Sign in with Azure CLI

Authenticating with a service principal is the best way to write secure scripts or programs

Sign in with a service principal

Upvotes: 1

Related Questions