Skip to content

Azure wasb hook is creating a container when getting a blob client #18237

Description

@ignaski

Apache Airflow Provider(s)

microsoft-azure

Versions of Apache Airflow Providers

apache-airflow-providers-microsoft-azure==3.1.1

Apache Airflow version

2.1.2

Operating System

OSX

Deployment

Docker-Compose

Deployment details

No response

What happened

_get_blob_client method in the wasb hook is trying to create a container

What you expected to happen

I expect to get a container client of an existing container

How to reproduce

No response

Anything else

I believe the fix is minor, e.g.

def _get_blob_client(self, container_name: str, blob_name: str) -> BlobClient:
        """
        Instantiates a blob client

        :param container_name: The name of the blob container
        :type container_name: str
        :param blob_name: The name of the blob. This needs not be existing
        :type blob_name: str
        """
        container_client = self.create_container(container_name)
        return container_client.get_blob_client(blob_name)

should be changed to

def _get_blob_client(self, container_name: str, blob_name: str) -> BlobClient:
        """
        Instantiates a blob client

        :param container_name: The name of the blob container
        :type container_name: str
        :param blob_name: The name of the blob. This needs not be existing
        :type blob_name: str
        """
        container_client = self._get_container_client(container_name)
        return container_client.get_blob_client(blob_name)

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions