# Buggy code
def _create_pipeline(self, credential, **kwargs):
    # type: (Any, **Any) -> Tuple[Configuration, Pipeline]
    self._credential_policy = None
    if hasattr(credential, "get_token"):
        self._credential_policy = BearerTokenCredentialPolicy(
            credential, STORAGE_OAUTH_SCOPE
        )
    elif isinstance(credential, SharedKeyCredentialPolicy):
        self._credential_policy = credential
    elif credential is not None:
        raise TypeError("Unsupported credential: {}".format(credential))

    config = kwargs.get("_configuration") or create_configuration(**kwargs)
    if kwargs.get("_pipeline"):
        return config, kwargs["_pipeline"]
    config.transport = kwargs.get("transport")  # type: ignore
    kwargs.setdefault("connection_timeout", CONNECTION_TIMEOUT)
    kwargs.setdefault("read_timeout", READ_TIMEOUT)
    if not config.transport:
        config.transport = RequestsTransport(**kwargs)
    policies = [
        QueueMessagePolicy(),
        config.headers_policy,
        config.proxy_policy,
        config.user_agent_policy,
        StorageContentValidation(),
        StorageRequestHook(**kwargs),
        self._credential_policy,
        ContentDecodePolicy(response_encoding="utf-8"),
        RedirectPolicy(**kwargs),
        StorageHosts(hosts=self._hosts, **kwargs),
        config.retry_policy,
        config.logging_policy,
        StorageResponseHook(**kwargs),
        DistributedTracingPolicy(**kwargs),
        HttpLoggingPolicy(**kwargs),
    ]
    if kwargs.get("_additional_pipeline_policies"):
        policies = policies + kwargs.get("_additional_pipeline_policies")
    return config, Pipeline(config.transport, policies=policies)


# Traceback (TimeoutError)
Fatal read error on socket transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f1cf667a5c0>
transport: <_SelectorSocketTransport fd=121 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
File "/home/azureuser/genfiles/external/python_runtime/python3/lib/python3.6/asyncio/selector_events.py", line 727, in _read_ready
data = self._sock.recv(self.max_size)
TimeoutError: [Errno 110] Connection timed out
ERROR    2020-09-08 16:08:45,961 customclass load_blob_file status=error, duration_ms=958266.8999999999
Traceback (most recent call last):
File "/home/azureuser/bin/azureuser/azure/storage/blob/aio/_download_async.py", line 271, in _initial_request
**self._request_options)
File "/home/azureuser/bin/azureuser/azure/storage/blob/_generated/aio/operations_async/_blob_operations_async.py", line 169, in download
raise models.StorageErrorException(response, self._deserialize)
azure.storage.blob._generated.models._models_py3.StorageErrorException: Operation returned an invalid status 'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/azureuser/bin/azureuser/services/storage/blob_storage/blob_loader_storage.py", line 128, in load_blob_file
file = self._hot_storage.load_file(file_id)
File "/home/azureuser/bin/azureuser/services/storage/blob_storage/azure_blob_storage.py", line 60, in load_file
loop=self._get_or_create_event_loop(),
File "/home/azureuser/genfiles/external/python_runtime/python3/lib/python3.6/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/home/azureuser/genfiles/external/python_runtime/python3/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/azureuser/bin/azureuser/services/storage/blob_storage/azure_blob_storage.py", line 79, in _load_blob_async_into_byte_stream
storage_stream_downloader = await blob_client.download_blob()
File "/home/azureuser/bin/azureuser/azure/core/tracing/decorator_async.py", line 74, in wrapper_use_tracer
return await func(*args, **kwargs)
File "/home/azureuser/bin/azureuser/azure/storage/blob/aio/_blob_client_async.py", line 335, in download_blob
await downloader._setup()  # pylint: disable=protected-access
File "/home/azureuser/bin/azureuser/azure/storage/blob/aio/_download_async.py", line 225, in _setup
self._response = await self._initial_request()
File "/home/azureuser/bin/azureuser/azure/storage/blob/aio/_download_async.py", line 306, in _initial_request
process_storage_error(error)
File "/home/azureuser/bin/azureuser/azure/storage/blob/_shared/response_handlers.py", line 147, in process_storage_error
raise error
azure.core.exceptions.ClientAuthenticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:4a1422e8-101e-0039-72fa-85b01b000000
Time:2020-09-08T16:08:45.9594457Z
ErrorCode:AuthenticationFailed
Error:None
AuthenticationErrorDetail:Request date header too old: 'Tue, 08 Sep 2020 15:52:47 GMT'
ERROR    2020-09-08 16:08:45,963 customclass loader_fetch_batch_load_data status=error, duration_ms=958596.6
Traceback (most recent call last):
File "/home/azureuser/bin/azureuser/azure/storage/blob/aio/_download_async.py", line 271, in _initial_request
**self._request_options)
File "/home/azureuser/bin/azureuser/azure/storage/blob/_generated/aio/operations_async/_blob_operations_async.py", line 169, in download
raise models.StorageErrorException(response, self._deserialize)
azure.storage.blob._generated.models._models_py3.StorageErrorException: Operation returned an invalid status 'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.'

# Fixed code
def _create_pipeline(self, credential, **kwargs):
    # type: (Any, **Any) -> Tuple[Configuration, Pipeline]
    self._credential_policy = None
    if hasattr(credential, "get_token"):
        self._credential_policy = BearerTokenCredentialPolicy(
            credential, STORAGE_OAUTH_SCOPE
        )
    elif isinstance(credential, SharedKeyCredentialPolicy):
        self._credential_policy = credential
    elif credential is not None:
        raise TypeError("Unsupported credential: {}".format(credential))

    config = kwargs.get("_configuration") or create_configuration(**kwargs)
    if kwargs.get("_pipeline"):
        return config, kwargs["_pipeline"]
    config.transport = kwargs.get("transport")  # type: ignore
    kwargs.setdefault("connection_timeout", CONNECTION_TIMEOUT)
    kwargs.setdefault("read_timeout", READ_TIMEOUT)
    if not config.transport:
        config.transport = RequestsTransport(**kwargs)
    policies = [
        QueueMessagePolicy(),
        config.proxy_policy,
        config.user_agent_policy,
        StorageContentValidation(),
        ContentDecodePolicy(response_encoding="utf-8"),
        RedirectPolicy(**kwargs),
        StorageHosts(hosts=self._hosts, **kwargs),
        config.retry_policy,
        config.headers_policy,
        StorageRequestHook(**kwargs),
        self._credential_policy,
        config.logging_policy,
        StorageResponseHook(**kwargs),
        DistributedTracingPolicy(**kwargs),
        HttpLoggingPolicy(**kwargs),
    ]
    if kwargs.get("_additional_pipeline_policies"):
        policies = policies + kwargs.get("_additional_pipeline_policies")
    return config, Pipeline(config.transport, policies=policies)