Skip to content

AzureBlobLuggageStore: ConnectionString with ContainerName always throws ArgumentException #4478

Description

@gitmln

Describe the bug

AzureBlobLuggageOptions offers two ways to connect: ContainerUri with Credential, or ConnectionString with ContainerName. The second one cannot be used at the moment, because the check in the constructor is inverted:

else if (string.IsNullOrEmpty(options.ContainerName) && string.IsNullOrEmpty(options.ConnectionString))
{
    _blobClient = new BlobContainerClient(options.ConnectionString, options.ContainerName);
}
else
{
    throw new ArgumentException("", nameof(options));
}

With both values set, the constructor throws an ArgumentException with an empty message. The tests in Paramore.Brighter.Azure.Tests construct the store only with ContainerUri and AzureCliCredential, which is probably why this has not come up.

The options' own XML docs describe the connection-string path as "Suitable for development or when using shared access signatures (SAS) or account keys via a connection string". For Azurite, which serves plain http by default, it is also the only path: the ContainerUri one fails there, because the SDK refuses a TokenCredential over http ("Cannot use TokenCredential without HTTPS").

The fix looks small: negate both checks, and name the two supported combinations in the exception message.

To Reproduce

var store = new AzureBlobLuggageStore(new AzureBlobLuggageOptions
{
    ConnectionString = "UseDevelopmentStorage=true",
    ContainerName = "luggage"
});

Exceptions (if any)

System.ArgumentException:  (Parameter 'options')

Further technical details

  • Brighter version: 10.7.0
  • Azure.Storage.Blobs 12.29.1

Prepared with help of an AI assistant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions