Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Azure Storage Laravel Package

matthewbdaly/laravel-azure-storage

Deprecated (March 2024): Azure Blob Storage driver for Laravel’s Storage API via Flysystem 3 Azure adapter. Provides a custom “azure” disk for Blob containers/URLs. Use the maintained replacement: https://github.com/Azure-OSS/azure-storage-php-adapter-laravel

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package via Composer:
    composer require matthewbdaly/laravel-azure-storage
    
  2. Register the service provider (optional for Laravel ≥5.5 auto-discovery; for older versions, add Matthewbdaly\LaravelAzureStorage\AzureStorageServiceProvider::class to config/app.php).
  3. Configure a new disk in config/filesystems.php:
    'azure' => [
        'driver' => 'azure',
        'account_name' => env('AZURE_STORAGE_ACCOUNT_NAME'),
        'account_key' => env('AZURE_STORAGE_ACCOUNT_KEY'),
        'container' => env('AZURE_STORAGE_CONTAINER', 'default'),
        'endpoint' => env('AZURE_STORAGE_ENDPOINT', 'core.windows.net'),
    ],
    
  4. Set credentials in .env:
    AZURE_STORAGE_ACCOUNT_NAME=your_account_name
    AZURE_STORAGE_ACCOUNT_KEY=your_base64_encoded_key
    AZURE_STORAGE_CONTAINER=my-app-files
    
  5. First use: Store a file using the Storage facade:
    use Illuminate\Support\Facades\Storage;
    
    Storage::disk('azure')->put('test.txt', 'Hello from Azure!');
    

Implementation Patterns

  • Switch disks dynamically: Use Storage::disk('azure') instead of the default local disk—ideal for multi-tenant or hybrid storage setups (e.g., local for dev, azure for prod).
  • Laravel File Uploads: Integrate with form requests:
    $path = $request->file('avatar')->store('avatars', 'azure');
    
  • Generating signed URLs: Use temporaryUrl() for time-limited public access (requires Azure SAS support via underlying Flysystem adapter):
    $url = Storage::disk('azure')->temporaryUrl('private/report.pdf', now()->addHour());
    
  • Batch operations: Efficiently list or delete files in bulk:
    $files = Storage::disk('azure')->listFiles('uploads/');
    Storage::disk('azure')->delete($files);
    
  • Visibility control: Set default visibility in config or per-file:
    Storage::disk('azure')->put('public/file.png', $contents, 'public');
    

Gotchas and Tips

  • Account key format: Ensure AZURE_STORAGE_ACCOUNT_KEY is the base64-encoded primary/secondary key from the Azure portal—not the raw hex string. Missing this causes authentication failures.
  • Container naming rules: Azure container names must be lowercase, 3–63 chars, and cannot start/end with - or contain consecutive hyphens. Enforce this in config or migration scripts.
  • No atomic rename/move: Azure Blob Storage doesn’t support native rename; the driver emulates it via copy+delete—expensive for large files. Prefer copy() explicitly when migration paths matter.
  • CORS and public access: If serving files directly to browsers (e.g., via temporaryUrl()), configure CORS rules in Azure Storage Account > CORS settings; otherwise, browser requests may be blocked.
  • Archived package status: Since the repo is archived (as of 2022), verify compatibility with newer Laravel/Flysystem versions (e.g., Laravel 10+ may require manual adapter wiring or use of league/flysystem-azure-blob-storage directly).
  • Testing locally: Use azurite (Azure Storage Emulator) in Docker to mock Azure Blob Storage during development:
    docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport