Skip to content

Commit 939778e

Browse files
authored
{Auth} Do not wrap MSIAuthenticationWrapper with CredentialAdaptor (#30962)
1 parent 2690e05 commit 939778e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/azure-cli-core/azure/cli/core/_profile.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,10 @@ def _create_subscription_client(self, credential):
926926
raise CLIInternalError("Unable to get '{}' in profile '{}'"
927927
.format(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, self.cli_ctx.cloud.profile))
928928
api_version = get_api_version(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
929-
sdk_cred = CredentialAdaptor(credential)
929+
930+
# MSIAuthenticationWrapper already implements get_token, so no need to wrap it with CredentialAdaptor
931+
from azure.cli.core.auth.adal_authentication import MSIAuthenticationWrapper
932+
sdk_cred = credential if isinstance(credential, MSIAuthenticationWrapper) else CredentialAdaptor(credential)
930933
client_kwargs = _prepare_mgmt_client_kwargs_track2(self.cli_ctx, sdk_cred)
931934
client = client_type(sdk_cred, api_version=api_version,
932935
base_url=self.cli_ctx.cloud.endpoints.resource_manager,

0 commit comments

Comments
 (0)