From 6c9cb05cfd017d4988c09d4654447246850684f9 Mon Sep 17 00:00:00 2001 From: Peter Hoffmann Date: Fri, 27 Jan 2017 13:20:04 +0100 Subject: [PATCH] Use tenant in UserPassCredentials if set. If you have multiple Tenants you need to set the tenant in https://github.com/Azure/msrestazure-for-python/blob/master/msrestazure/azure_active_directory.py otherwise the azure_rm.py call will fail. --- contrib/inventory/azure_rm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/inventory/azure_rm.py b/contrib/inventory/azure_rm.py index 6c77f20f24b..955a31d8a53 100755 --- a/contrib/inventory/azure_rm.py +++ b/contrib/inventory/azure_rm.py @@ -274,7 +274,11 @@ class AzureRM(object): secret=self.credentials['secret'], tenant=self.credentials['tenant']) elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None: - self.azure_credentials = UserPassCredentials(self.credentials['ad_user'], self.credentials['password']) + tenant = self.credentials.get('tenant') + if tenant is not None: + self.azure_credentials = UserPassCredentials(self.credentials['ad_user'], self.credentials['password'], tenant=tenant) + else: + self.azure_credentials = UserPassCredentials(self.credentials['ad_user'], self.credentials['password']) else: self.fail("Failed to authenticate with provided credentials. Some attributes were missing. " "Credentials must include client_id, secret and tenant or ad_user and password.")