From 5a34f307b25cbedae7d7e204d275f5f15b844668 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Tue, 30 Mar 2021 14:20:37 +0800 Subject: [PATCH 1/2] Quick patch for managed_by_tenants missing from response --- src/azure-cli-core/azure/cli/core/_profile.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index ddb80d4e2e9..aa9d59e259f 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -271,16 +271,7 @@ def _normalize_properties(self, user, subscriptions, is_service_principal, cert_ if subscription_dict[_SUBSCRIPTION_NAME] != _TENANT_LEVEL_ACCOUNT_NAME: if hasattr(s, 'home_tenant_id'): subscription_dict[_HOME_TENANT_ID] = s.home_tenant_id - if hasattr(s, 'managed_by_tenants'): - if s.managed_by_tenants is None: - # managedByTenants is missing from the response. This is a known service issue: - # https://github.com/Azure/azure-rest-api-specs/issues/9567 - # pylint: disable=line-too-long - raise CLIError("Invalid profile is used for cloud '{cloud_name}'. " - "To configure the cloud profile, run `az cloud set --name {cloud_name} --profile (e.g. 2019-03-01-hybrid)`. " - "For more information about using Azure CLI with Azure Stack, see " - "https://docs.microsoft.com/azure-stack/user/azure-stack-version-profiles-azurecli2" - .format(cloud_name=self.cli_ctx.cloud.name)) + if getattr(s, 'managed_by_tenants', None): subscription_dict[_MANAGED_BY_TENANTS] = [{_TENANT_ID: t.tenant_id} for t in s.managed_by_tenants] consolidated.append(subscription_dict) From 8ba86f95986039567ce4035117dc6ed9033e3a17 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Tue, 30 Mar 2021 14:57:46 +0800 Subject: [PATCH 2/2] keep [] --- src/azure-cli-core/azure/cli/core/_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index aa9d59e259f..9d34f10a35e 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -271,7 +271,7 @@ def _normalize_properties(self, user, subscriptions, is_service_principal, cert_ if subscription_dict[_SUBSCRIPTION_NAME] != _TENANT_LEVEL_ACCOUNT_NAME: if hasattr(s, 'home_tenant_id'): subscription_dict[_HOME_TENANT_ID] = s.home_tenant_id - if getattr(s, 'managed_by_tenants', None): + if getattr(s, 'managed_by_tenants', None) is not None: subscription_dict[_MANAGED_BY_TENANTS] = [{_TENANT_ID: t.tenant_id} for t in s.managed_by_tenants] consolidated.append(subscription_dict)