Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] CLI assumes the AZURE_LOGIN_CONFIG file has subscriptions in it #890

Open
rhuanbarreto opened this issue Sep 28, 2024 · 1 comment

Comments

@rhuanbarreto
Copy link

rhuanbarreto commented Sep 28, 2024

I'm using the latest version 2.0.1

Describe the bug
CLI is failing to deploy when reading the contents of my AZURE_LOGIN_CONFIG file. Logs below:

✖ Cannot read properties of undefined (reading 'find')
✔ Successfully logged into Azure!
Found an existing Azure config file, getting Tenant and Subscription Id from /home/vsts/.azure/azureProfile.json

This is the content of my azureProfile.json:

{"installationId": "redacteduuid"}

I could track down the error to be on this statement:

const defaultAzureInfo = allSubscriptions.find((subscription) => subscription.isDefault == true);

And the line before coerces the configuration to an interface:

const allSubscriptions = (azureProfile as AzureProfile).subscriptions;

Which resolves to this interface:

declare interface AzureProfile {
installationId: string;
subscriptions: AzureLoginInfo[];
}

Which is not true. My azureProfile.json doesn't have the subscriptions key. Therefore the failure.

To Reproduce
Steps to reproduce the behavior:

  1. Make a pipeline in Azure Dev Ops
  2. Use a service principal logging in with client ID and client secret in an AzureCLI@2 task
  3. Inside of an AzureCLI@2 task, run the SWA CLI commands via an inline script
  4. See error. The command will not fail despite the failure which makes debugging very hard once CI will never fail.

Expected behavior

Expected to have the command working fine.

@rhuanbarreto
Copy link
Author

I managed to solve the problem by setting the "Use global Azure CLI configuration" option in the pipeline step. But this still doesn't solve the bug. The CLI must check for the existence of the subscriptions key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant