From 2fcae8b367a53d9a80d6e50abbfb9af425ec4368 Mon Sep 17 00:00:00 2001 From: Yunge Zhu <37337818+yungezz@users.noreply.github.com> Date: Fri, 7 Sep 2018 22:12:06 +0800 Subject: [PATCH] Cherrypick stable2.7 44802 (#45332) * fix blob in non-public azure cloud (#44802) (cherry picked from commit b58141555d7dfb6b1064216b36e26c26902d4a14) --- .../fragments/azure-storage-cloud-environment.yaml | 3 +++ lib/ansible/module_utils/azure_rm_common.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/azure-storage-cloud-environment.yaml diff --git a/changelogs/fragments/azure-storage-cloud-environment.yaml b/changelogs/fragments/azure-storage-cloud-environment.yaml new file mode 100644 index 00000000000..80999997ce2 --- /dev/null +++ b/changelogs/fragments/azure-storage-cloud-environment.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- fix azure storage blob cannot create blob container in non-public azure cloud environment. (https://github.com/ansible/ansible/issues/35223) \ No newline at end of file diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index 00886e813ba..6b304b27064 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -154,6 +154,7 @@ try: from azure.mgmt.marketplaceordering import MarketplaceOrderingAgreements from azure.mgmt.trafficmanager import TrafficManagerManagementClient from azure.storage.cloudstorageaccount import CloudStorageAccount + from azure.storage.blob import PageBlobService, BlockBlobService from adal.authentication_context import AuthenticationContext from azure.mgmt.sql import SqlManagementClient from azure.mgmt.rdbms.postgresql import PostgreSQLManagementClient @@ -533,9 +534,13 @@ class AzureRMModuleBase(object): try: self.log('Create blob service') if storage_blob_type == 'page': - return CloudStorageAccount(storage_account_name, account_keys.keys[0].value).create_page_blob_service() + return PageBlobService(endpoint_suffix=self._cloud_environment.suffixes.storage_endpoint, + account_name=storage_account_name, + account_key=account_keys.keys[0].value) elif storage_blob_type == 'block': - return CloudStorageAccount(storage_account_name, account_keys.keys[0].value).create_block_blob_service() + return BlockBlobService(endpoint_suffix=self._cloud_environment.suffixes.storage_endpoint, + account_name=storage_account_name, + account_key=account_keys.keys[0].value) else: raise Exception("Invalid storage blob type defined.") except Exception as exc: