Skip to content

[BUG] Misleading NIO URI format documentation #39579

@ejschoen

Description

@ejschoen

Describe the bug

Not really a bug. More a documentation issue, although some additional validation of azb: URI's might help.

The README for NIO documents the URI format as azb://?endpoint=storage-account-name.blob.core.windows.net. It's very easy to think you should create a URI of the form azb://container-name:/path/to/file?endpoint=... This is technically wrong because the container name is in the host name spot and not the first element of the path. However, this works, but only if the file being referenced is in the first container in the list of containers passed to the newFileSystem call when the Azure file system is initialized. The file system will happily create azb://second-container-name:/path/to/another/file?endpoint=... as a path, but that path won't work. It only works if the URI is of the form azb:/second-container-name:/path/to/another/file?endpoint=...

Code Snippet
Add the code snippet that causes the issue.

                    StorageSharedKeyCredential creds = new StorageSharedKeyCredential(keyconfig.get("accountname"),
                                                                                      keyconfig.get("accountkey"));
                    HashMap config = new HashMap();
                    config.put(AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL, creds);
                    config.put(AzureFileSystem.AZURE_STORAGE_FILE_STORES, azure_containers);
                    FileSystems.newFileSystem(new URI(String.format("azb://?endpoint=%s", azure_endpoint)), 

where azure_containers is something like `"container1,container2"

Then:

path1 = Paths.get(new URI("azb://container1:/path/to/existing-file-in-container1"))
path1.exists() => true

but

path2 = Paths.get(new URI("azb://container2:/path/to/existing-file-in-container2"))
path2.exists() => false

whereas:

path2a = Paths.get(new URI("azb:/container2:/path/to/existing-file-in-container2"))
path2a.exists() => true

Expected behavior
Naively reading the docs for NIO, I'd expect both .exists tests to return true. If I use a single slash after the scheme, it works as expected, but the docs example shows 2 slashes. It does say that the container name has to be the first element of the URI path, but that's a little bit subtle. Some warning that double slashes after the azb: scheme are not needed, and could be harmful would be helpful.

Setup (please complete the following information):

  • OS: Linux
  • IDE: None
  • Library/Libraries: azure-storage-blob-nio
  • Java version: [e.g. 8] 8
  • App Server/Environment: Clojure
  • Frameworks: [None

I

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.javadoc-improvementneeds-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions