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

Merged
merged 1 commit into from
Nov 20, 2024
Merged
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
17 changes: 9 additions & 8 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def login(self,
return deepcopy(consolidated)

def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=None):
if _on_azure_arc_windows():
return self.login_with_managed_identity_azure_arc_windows(
if _on_azure_arc():
return self.login_with_managed_identity_azure_arc(
identity_id=identity_id, allow_no_subscriptions=allow_no_subscriptions)

import jwt
Expand Down Expand Up @@ -286,7 +286,7 @@ def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=N
self._set_subscriptions(consolidated)
return deepcopy(consolidated)

def login_with_managed_identity_azure_arc_windows(self, identity_id=None, allow_no_subscriptions=None):
def login_with_managed_identity_azure_arc(self, identity_id=None, allow_no_subscriptions=None):
import jwt
identity_type = MsiAccountTypes.system_assigned
from .auth.msal_credentials import ManagedIdentityCredential
Expand Down Expand Up @@ -388,7 +388,7 @@ def get_login_credentials(self, resource=None, subscription_id=None, aux_subscri

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 @@ -449,7 +449,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, authority, tenant_id=None, client_id=None
instance_discovery=instance_discovery)


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