Adding support for Azure MSI user-assigned identity (#54884)

If more than one user-assigned identity is assigned to a host, then an identifier is required to specify which credentials are retrieved.  This change uses the existing support for client_id to retrieve the user-assigned identity by client_id.
pull/55699/head
Aaron D 6 years ago committed by Zim Kalinowski
parent 35fdae7485
commit 204db4d044

@ -1149,8 +1149,9 @@ class AzureRMAuth(object):
return None return None
def _get_msi_credentials(self, subscription_id_param=None): def _get_msi_credentials(self, subscription_id_param=None, **kwargs):
credentials = MSIAuthentication() client_id = kwargs.get('client_id', None)
credentials = MSIAuthentication(client_id=client_id)
subscription_id = subscription_id_param or os.environ.get(AZURE_CREDENTIAL_ENV_MAPPING['subscription_id'], None) subscription_id = subscription_id_param or os.environ.get(AZURE_CREDENTIAL_ENV_MAPPING['subscription_id'], None)
if not subscription_id: if not subscription_id:
try: try:
@ -1206,7 +1207,7 @@ class AzureRMAuth(object):
if auth_source == 'msi': if auth_source == 'msi':
self.log('Retrieving credenitals from MSI') self.log('Retrieving credenitals from MSI')
return self._get_msi_credentials(arg_credentials['subscription_id']) return self._get_msi_credentials(arg_credentials['subscription_id'], client_id=params.get('client_id', None))
if auth_source == 'cli': if auth_source == 'cli':
if not HAS_AZURE_CLI_CORE: if not HAS_AZURE_CLI_CORE:

Loading…
Cancel
Save