简体   繁体   中英

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?

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM