-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} az login: Capture managed_by_tenants error #15550
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
Conversation
| from azure.cli.core.azclierror import UserFault | ||
| raise UserFault("Invalid profile is used for cloud '{cloud_name}'. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define an error sub-class may be InvalidProfileError(UserFault) and raise the specific error? UserFault is designed as an abstract class and is not recommended to be raised directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a temporary mitigation to the service bug, it should actually be an Unsupported API version error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@houk-ms , you can use ABC and abstractmethod (from abc import ABC, abstractmethod) to define your class and make the parent class can't be instantiated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arrownj sure, we can do that. Maybe in next CLI release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiasli In this case, cosider using from azure.cli.core.azclierror import UnknownError to replace UserFault if you don't define a new error type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use CLIError for now until the error can be classified as UnsupportedAPIError after the service is fixed.
|
Core |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
This PR has been shipped in Azure CLI 2.15.0. |
Fix #14969
Description
If profile
latestis used for Azure Stack cloud,az loginwill fail:This is because
latestshould not be accepted by the service, and the service should returnNot Supported. On the contrary, the service does accept the request and returns an invalid JSON which lacksmanagedByTenants. This behavior doesn't comply with the spec (Azure/azure-rest-api-specs#9567), causing the parsing logic of CLI to fail.Ideally, the user should run
az cloud set/update -n redmond --profile 2019-03-01-hybridto set the profile for the cloud beforeaz login.This PR wraps the raw exception with better instructions: