-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} Remove the check on managed_by_tenants
#17526
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
managed_by_tenantsmanaged_by_tenants
|
Remove check on managed_by_tenants |
yonzhan
left a comment
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.
LGTM
| if s.managed_by_tenants is None: | ||
| s_dict[_MANAGED_BY_TENANTS] = None |
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.
Consider following steps:
- ARM REST API response omits
managedByTenants(or returns"managedByTenants": null, though never observed) - Python SDK will still have
managed_by_tenants: None - As a consequence, Azure CLI output will have
"managedByTenants": null
This behavior is a breaking change and doesn't comply with swagger as empty array [] becomes null (null is no longer an array), so users assuming managedByTenants to be an array may also face failure.
"managedByTenants": {
"type": "array",
"items": {
"$ref": "#/definitions/ManagedByTenant"
},
"description": "An array containing the tenants managing the subscription."
},Actually, there is no way to perfectly handle all kinds of REST API changes or behaviors in the gray area. In my humble opinion, making API consistent and comply with the swagger is the best and ultimate solution.
In this case,
managedByTenantsproperty MUST existmanagedByTenantsMUST be an array, notnull
https://learn.microsoft.com/en-us/rest/api/resources/subscriptions/list?tabs=HTTP
|
This PR has been shipped in Azure CLI 2.22.0. |

Description
Fix #17509
When
latestor2019-06-01is used for Azure Stack/subscription, the REST response doesn't havemanagedByTenants. However, because the REST spec defines it, theSubscriptionobject returned by SDK will havemanaged_by_tenantsasNone. In such case, the behavior of this PR differs from the patch provided in {Core} Quick patch formanaged_by_tenantsmissing from response #17509:managed_by_tenantsmissing from response #17509: CLI doesn't returnmanagedByTenants, following the actual REST responsemanagedByTenants, but sets it tonull, following the REST specWhen
2019-03-01-hybridor2016-06-01is used for Azure Stack/subscription, the REST response doesn't havemanagedByTenants. Because the REST spec doesn't define it, theSubscriptionobject returned by SDK doesn't havemanaged_by_tenants, so CLI ignores it. This is the same as {Core} Quick patch formanaged_by_tenantsmissing from response #17509.Additional Context
When SDK object has
managed_by_tenantsasNone, CLI can't distinguish betweenmanagedByTenantsmanagedByTenantsasnull(Luckily, this has never been observed.)By disabling this check in the gatekeeper
az login, CLI may fail even deeper in other commands because the profile / API version is incorrect after all. The handling of unsupported API will be more difficult, but Azure Stack team confirms this is acceptable.