Skip to content

BlobClient.from_blob_url() invalid URL if host is localhost/127.0.0.1  #15882

@phergo

Description

@phergo
  • Package Name: azure.storage.blob
  • Package Version: 12.6.0 (also seen on 12.4.0 and 12.5.0; no issue on 12.3.0)
  • Operating System: macOS High Sierra 10.13.6
  • Python Version: 3.8.5 (also tested in 3.7.4)

Describe the bug
When instantiating a BlobClient object through .from_blob_url() method using a localhost/127.0.0.1 address, the resulting object's url attribute is different to the specified URL; specifically, the URL attribute is missing a slash between the host (with or without TCP port) and the storage account name. The incorrect URL means methods such as .download_blob() does not work.

For example, if a BlobClient object is created as:
bc = BlobClient.from_blob_url('http://127.0.0.1:10000/devstoreaccount1/container1/folder1/file.csv')

The resulting bc.url attribute is incorrectly reported as below (note the missing slash right after 127.0.0.1:10000):
http://127.0.0.1:10000devstoreaccount1/container1/folder1/file.csv

Even though the full URL is not valid, both container_name and blob_name are correctly parsed from the URL, as 'container1' and 'folder1/file.csv' respectively.

The same behavior has been seen in azure.storage.blob package versions 12.4.0, 12.5.0 and 12.6.0; however, the result is correct in 12.3.0. The same results were obtained in python 3.7.4 and 3.8.5.

The results seem to be correct, though, with any server name/address other than localhost or 127.0.0.1.

To Reproduce

  1. Simple fully working test script (credentials and other non-relevant items ignored):
    from azure.storage.blob import BlobClient
    url = 'http://127.0.0.1:10000/devstoreaccount1/container1/folder1/file.csv'
    bc = BlobClient.from_blob_url(blob_url=url)
    assert url == bc.url
    

Expected behavior
The BlobClient url attribute should be the same as the url provided as argument to the .from_blob_url() method.

Screenshots
N/A

Additional context
Developing/Testing locally using VSCode (1.52.1) with Azurite (3.10.0) extension.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.StorageStorage Service (Queues, Blobs, Files)bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions