{Core} az login: Capture managed_by_tenants error#15550
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.
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.
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.
@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.
@arrownj sure, we can do that. Maybe in next CLI release
There was a problem hiding this comment.
@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.
Let's use CLIError for now until the error can be classified as UnsupportedAPIError after the service is fixed.
|
Core |
Co-authored-by: Feng Zhou <55177366+fengzhou-msft@users.noreply.github.com>
|
/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: