1

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?

4
  • What is the platform you would use for CI/CD? Azure DevOps? Commented Sep 22, 2020 at 13:10
  • @KrishnenduGhosh-MSFT I use Jenkins Commented Sep 22, 2020 at 13:30
  • Thanks. Posted the answer. Commented Sep 22, 2020 at 14:01
  • Thanks! I had missed the fact that there is a different login command set for service principals than normal login Commented Sep 22, 2020 at 16:19

2 Answers 2

1

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/

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.