Azure CLI - Login Error Inside "Deploy Package" Step

Hi,

I’m currently facing an issue with a deployment script inside a “Deploy a Package” step: when running this Azure CLI command az login --service-principal -u $ServicePrincipal -p $ClientSecret --tenant $AzureTenant --subscription $SubscriptionId, the step returns the following: ERROR: Please run 'az login' to setup account..
All variables are set correctly, Azure CLI has been configured on the Octopus Server and the script works when executed locally on the Octopus Server. We’re not using any Proxy. I’ve tried the solutions from github article 4828 and from topic 20795 to no avail.
The script also sets $env:Path += ";C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin"; $env:AZURE_CONFIG_DIR = $PSScriptRoot environment variables.

Any ideas on how to get pass this error?

Hi,

Thanks for getting in touch! That definitely is a bit strange as az login is obviously in the Azure CLI command. I wonder if there’s a null value being passed in somewhere and causing this issue. Can you confirm if that’s what’s causing this in your setup by enabling debugging variables and creating and deploying a new release? This will log every variable available at the beginning of each step, and their values after evaluation. The process to produce this verbose log is shown in the following doc page.

I’ll be happy to look at it as well. Feel free to email it to us at support at octopus dot com, or mark this thread as private and attach it here. :slight_smile:

I look forward to hearing back and getting to the bottom of this one!

Best regards,

Kenny

Hi Kenny,

Unfortunately, the variables contain the right information. I’ve also verified the values from the “debugging variables” log.
image
Is there some other information that would be relevant to have? Calamari version 4.10.0, Octopus v2018.10.0 LTS.

Thanks and best regards,
Etienne

I added --debug to my az login command, which pointed-out where Azure CLI was failling. It gave me this:
DEBUG: Event: CommandInvoker.OnPostParseArgs [<functionOutputProducer.handle_output_argument at 0x017F10C0>, <functionCLIQuery.handle_query_parameter at 0x018099C0>, <functionregister_global_subscription_parameter.<locals>.parse_subscription_parameter at 0x01889468>, <function handler at 0x01AE7030>]
ERROR: Please run 'az login' to setup account.

So, the error is with parse_subscription_parameter.

Now, instead of my one-liner, I use:
az login --service-principal -u $ServicePrincipal -p $ClientSecret --tenant $AzureTenant
az account set --subscription $SubscriptionId
Which logs-in and then selects the subscription.

I don’t know why Azure CLI / Octopus couldn’t load parse_subscription_parameter, but using these commands separately does the trick! :sweat_smile:

Hi Etienne,

Thanks for following up and taking the time outline the results of your troubleshooting! That’s great to hear you’re up and running, and I’m sure it’ll help someone else hitting this issue in the future.

Don’t hesitate to reach out if you have any further questions going forward. :slight_smile:

Best regards,

Kenny

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.