# Buggy code
def get_blob_client(
    self, resource_group_name, storage_account_name, storage_blob_type="block"
):
    keys = dict()
    try:
        # Get keys from the storage account
        self.log("Getting keys")
        account_keys = self.storage_client.storage_accounts.list_keys(
            resource_group_name, storage_account_name
        )
    except Exception as exc:
        self.fail(
            "Error getting keys for account {0} - {1}".format(
                storage_account_name, str(exc)
            )
        )

    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()
        elif storage_blob_type == "block":
            return CloudStorageAccount(
                storage_account_name, account_keys.keys[0].value
            ).create_block_blob_service()
        else:
            raise Exception("Invalid storage blob type defined.")
    except Exception as exc:
        self.fail(
            "Error creating blob service client for storage account {0} - {1}".format(
                storage_account_name, str(exc)
            )
        )


# Traceback (ConnectTimeoutError)
ConnectTimeout: HTTPSConnectionPool(host='blobname.blob.core.windows.net', port=443):

An exception occurred during task execution. To see the full traceback, use -vvv.
The error was: azure.common.AzureException: ConnectTimeout: HTTPSConnectionPool(host='blobname.blob.core.windows.net', port=443): Max retries exceeded with url: /datalake-feeder?restype=container (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x297b110>, 'Connection to blobname.blob.core.windows.net timed out. (connect timeout=20)'))

fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_T4Toi_/ansible_module_azure_rm_storageblob.py\", line 562, in <module>\n    main()\n  File \"/tmp/ansible_T4Toi_/ansible_module_azure_rm_storageblob.py\", line 559, in main\n    AzureRMStorageBlob()\n  File \"/tmp/ansible_T4Toi_/ansible_module_azure_rm_storageblob.py\", line 256, in __init__\n    supports_tags=True)\n  File \"/tmp/ansible_T4Toi_/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py\", line 285, in __init__\n  File \"/tmp/ansible_T4Toi_/ansible_module_azure_rm_storageblob.py\", line 268, in exec_module\n    self.container_obj = self.get_container()\n  File \"/tmp/ansible_T4Toi_/ansible_module_azure_rm_storageblob.py\", line 325, in get_container\n    container = self.blob_client.get_container_properties(self.container)\n  File \"/usr/lib/python2.7/site-packages/azure/storage/blob/baseblobservice.py\", line 635, in get_container_properties\n    return self._perform_request(request, _parse_container, [container_name])\n  File \"/usr/lib/python2.7/site-packages/azure/storage/storageclient.py\", line 280, in _perform_request\n    raise ex\nazure.common.AzureException: ConnectTimeout: HTTPSConnectionPool(host='blobname.blob.core.windows.net', port=443): Max retries exceeded with url: /datalake-feeder?restype=container (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x297b110>, 'Connection to blobname.blob.core.windows.net timed out. (connect timeout=20)'))\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}

# Fixed code
def get_blob_client(
    self, resource_group_name, storage_account_name, storage_blob_type="block"
):
    keys = dict()
    try:
        # Get keys from the storage account
        self.log("Getting keys")
        account_keys = self.storage_client.storage_accounts.list_keys(
            resource_group_name, storage_account_name
        )
    except Exception as exc:
        self.fail(
            "Error getting keys for account {0} - {1}".format(
                storage_account_name, str(exc)
            )
        )

    try:
        self.log("Create blob service")
        if storage_blob_type == "page":
            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 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:
        self.fail(
            "Error creating blob service client for storage account {0} - {1}".format(
                storage_account_name, str(exc)
            )
        )