[Bug] CLI assumes the AZURE_LOGIN_CONFIG file has subscriptions in it
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:
https://github.com/Azure/static-web-apps-cli/blob/5f440e3068be7d53e052fae17e58dcc5c8b108e5/src/cli/commands/login/login.ts#L165
And the line before coerces the configuration to an interface:
https://github.com/Azure/static-web-apps-cli/blob/5f440e3068be7d53e052fae17e58dcc5c8b108e5/src/cli/commands/login/login.ts#L164
Which resolves to this interface:
https://github.com/Azure/static-web-apps-cli/blob/5f440e3068be7d53e052fae17e58dcc5c8b108e5/src/swa.d.ts#L443-L446
Which is not true. My azureProfile.json doesn't have the subscriptions key. Therefore the failure.
To Reproduce Steps to reproduce the behavior:
- Make a pipeline in Azure Dev Ops
- Use a service principal logging in with client ID and client secret in an AzureCLI@2 task
- Inside of an AzureCLI@2 task, run the SWA CLI commands via an inline script
- 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.
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.
On my local laptop the environment variable AZURE_CONFIG_DIR is pointing to a specific customer folder, but still the swa cli is using the default %userprofile%.azure\azureProfile.json. Is that expected?