matthewbdaly/laravel-azure-storage

Instantiate from Connection String

derekrprice opened this issue · 4 comments

Is your feature request related to a problem? Please describe.
I'd like to instantiate the Filesystem with a connection string like this, which is published in the Azure Portal and which is what is passed as a secret to my docker container via CI/CD:

DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey];BlobEndpoint=<url>

I used to have my own code like this:

        $client = BlobRestProxy::createBlobService($connectionString);
        $adapter = new AzureBlobStorageAdapter($client, $container, $prefix);
        return new Filesystem($adapter);

This is quite concise. Now I have to write a class just to parse the connection string and pass it into this adapter as individual elements. This is more work than I used to do.

Describe the solution you'd like
The adapter should accept a single 'connection_string' configuration element in lieu of separate key. name, endpoint, etc.

Describe alternatives you've considered
Sticking with my own convenience class to return the Filesystem adapter.

Thanks for your suggestion.

I'd like to implement this at some point, but I'm not likely to have the time to do so in the near future - I don't currently work on anything that's using this in production.

If you'd like to submit a pull request for this functionality, I'll be happy to take a look at it.

#46 PR created. Let me know what do you think :) I've ran this in our app and it was fine (tested on Azurite emulator).

@matthewbdaly is there any chance to merge this and publish new version in reasonable time ?

@zaalbarxx It's merged in, and I've made a new release. I'm also planning another release in a couple of weeks once Laravel 9 and the relevant version of orchestra/testbench become available.