Skip to content
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

[Core] PREVIEW: Support managed identity on Azure Arc-enabled Linux server #30267

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def login(self,
return deepcopy(consolidated)

def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=None):
if _on_azure_arc_windows():
if _on_azure_arc():
return self.login_with_managed_identity_azure_arc_windows(
identity_id=identity_id, allow_no_subscriptions=allow_no_subscriptions)
Comment on lines +223 to 225
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if _on_azure_arc():
return self.login_with_managed_identity_azure_arc_windows(
identity_id=identity_id, allow_no_subscriptions=allow_no_subscriptions)
if _on_azure_arc():
return self.login_with_managed_identity_azure_arc(
identity_id=identity_id, allow_no_subscriptions=allow_no_subscriptions)


Expand Down Expand Up @@ -390,7 +390,7 @@ def get_login_credentials(self, resource=None, client_id=None, subscription_id=N

elif managed_identity_type:
# managed identity
if _on_azure_arc_windows():
if _on_azure_arc():
from .auth.msal_credentials import ManagedIdentityCredential
from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
# The credential must be wrapped by CredentialAdaptor so that it can work with Track 1 SDKs.
Expand Down Expand Up @@ -451,7 +451,7 @@ def get_raw_token(self, resource=None, scopes=None, subscription=None, tenant=No
# managed identity
if tenant:
raise CLIError("Tenant shouldn't be specified for managed identity account")
if _on_azure_arc_windows():
if _on_azure_arc():
from .auth.msal_credentials import ManagedIdentityCredential
cred = ManagedIdentityCredential()
else:
Expand Down Expand Up @@ -960,6 +960,7 @@ def _create_identity_instance(cli_ctx, *args, **kwargs):
instance_discovery=instance_discovery, **kwargs)


def _on_azure_arc_windows():
# This indicates an Azure Arc-enabled Windows server
return "IDENTITY_ENDPOINT" in os.environ and "IMDS_ENDPOINT" in os.environ
def _on_azure_arc():
# This indicates an Azure Arc-enabled server
from msal.managed_identity import get_managed_identity_source, AZURE_ARC
return get_managed_identity_source() == AZURE_ARC
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
'jmespath',
'knack~=0.11.0',
'msal-extensions==1.2.0',
'msal[broker]==1.31.0',
'msal[broker]==1.31.1',
'msrestazure~=0.6.4',
'packaging>=20.9',
'pkginfo>=1.5.0.1',
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jmespath==0.9.5
jsondiff==2.0.0
knack==0.11.0
msal-extensions==1.2.0
msal[broker]==1.31.0
msal[broker]==1.31.1
msrest==0.7.1
msrestazure==0.6.4
oauthlib==3.2.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jmespath==0.9.5
jsondiff==2.0.0
knack==0.11.0
msal-extensions==1.2.0
msal[broker]==1.31.0
msal[broker]==1.31.1
msrest==0.7.1
msrestazure==0.6.4
oauthlib==3.2.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jmespath==0.9.5
jsondiff==2.0.0
knack==0.11.0
msal-extensions==1.2.0
msal[broker]==1.31.0
msal[broker]==1.31.1
msrest==0.7.1
msrestazure==0.6.4
oauthlib==3.2.2
Expand Down
Loading