PHPackages                             alinauf/laravel-azure-storage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. alinauf/laravel-azure-storage

ActiveLibrary[File &amp; Storage](/categories/file-storage)

alinauf/laravel-azure-storage
=============================

Azure Blob Storage filesystem driver for Laravel using REST API

v1.1.0(3mo ago)1743—7.1%MITPHPPHP ^8.2CI passing

Since Jan 13Pushed 3mo agoCompare

[ Source](https://github.com/alinauf/laravel-azure-storage)[ Packagist](https://packagist.org/packages/alinauf/laravel-azure-storage)[ RSS](/packages/alinauf-laravel-azure-storage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Laravel Azure Storage
=====================

[](#laravel-azure-storage)

[![Tests](https://github.com/alinauf/laravel-azure-storage/actions/workflows/tests.yml/badge.svg)](https://github.com/alinauf/laravel-azure-storage/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/7b85af47b521dc9232a0eaf4789fa5acdf963105bf99bedf3e77082ba6046681/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c696e6175662f6c61726176656c2d617a7572652d73746f726167652e737667)](https://packagist.org/packages/alinauf/laravel-azure-storage)[![License](https://camo.githubusercontent.com/b978e1ebb0499861296920ba58b5caea9fa271cf36ba533423b99cbce5992c32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c696e6175662f6c61726176656c2d617a7572652d73746f726167652e737667)](https://packagist.org/packages/alinauf/laravel-azure-storage)

Azure Blob Storage filesystem driver for Laravel using the Azure REST API directly. No deprecated SDK dependencies.

Features
--------

[](#features)

- **Full Flysystem Integration** - Works seamlessly with Laravel's Storage facade
- **REST API Based** - Uses Azure Blob Storage REST API directly, no deprecated SDKs
- **Shared Key Authentication** - Secure HMAC-SHA256 authentication
- **SAS Token Support** - Generate temporary signed URLs for secure access
- **Full CRUD Operations** - Read, write, delete, copy, move files
- **Directory Operations** - List contents, delete directories
- **Metadata Support** - Get file size, last modified time, MIME type
- **CDN Support** - Custom URL support for Azure CDN or custom domains

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.0+ or 12.0+

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require alinauf/laravel-azure-storage
```

The service provider will be auto-discovered by Laravel.

### Publish Configuration (Optional)

[](#publish-configuration-optional)

```
php artisan vendor:publish --tag=azure-storage-config
```

Configuration
-------------

[](#configuration)

Add the following environment variables to your `.env` file:

```
AZURE_STORAGE_ACCOUNT_NAME=your-account-name
AZURE_STORAGE_ACCOUNT_KEY=your-account-key
AZURE_STORAGE_CONTAINER=your-container-name
AZURE_STORAGE_URL=https://your-cdn-url.com  # Optional: for CDN or custom domain
```

Then configure a disk in `config/filesystems.php`:

```
'disks' => [
    'azure' => [
        'driver' => 'azure',
        'account_name' => env('AZURE_STORAGE_ACCOUNT_NAME'),
        'account_key' => env('AZURE_STORAGE_ACCOUNT_KEY'),
        'container' => env('AZURE_STORAGE_CONTAINER'),
        'url' => env('AZURE_STORAGE_URL'),  // Optional
    ],
],
```

Usage
-----

[](#usage)

### Basic File Operations

[](#basic-file-operations)

```
use Illuminate\Support\Facades\Storage;

// Use the azure disk
$disk = Storage::disk('azure');

// Upload a file
$disk->put('path/to/file.txt', 'Contents');

// Upload from a stream
$disk->putStream('path/to/file.txt', fopen('/local/file.txt', 'r'));

// Read a file
$contents = $disk->get('path/to/file.txt');

// Check if file exists
if ($disk->exists('path/to/file.txt')) {
    // ...
}

// Delete a file
$disk->delete('path/to/file.txt');

// Copy a file
$disk->copy('source.txt', 'destination.txt');

// Move a file
$disk->move('old-location.txt', 'new-location.txt');
```

### Getting File Information

[](#getting-file-information)

```
// Get file size in bytes
$size = $disk->size('path/to/file.txt');

// Get last modified timestamp
$timestamp = $disk->lastModified('path/to/file.txt');

// Get MIME type
$mimeType = $disk->mimeType('path/to/file.txt');
```

### Directory Operations

[](#directory-operations)

```
// List files in a directory
$files = $disk->files('path/to/directory');

// List all files recursively
$allFiles = $disk->allFiles('path/to/directory');

// List directories
$directories = $disk->directories('path/to/directory');

// Delete a directory and all its contents
$disk->deleteDirectory('path/to/directory');
```

### URLs

[](#urls)

```
// Get the public URL
$url = $disk->url('path/to/file.jpg');
// Returns: https://your-account.blob.core.windows.net/container/path/to/file.jpg

// Generate a temporary signed URL (SAS token)
$url = $disk->temporaryUrl('path/to/file.jpg', now()->addHours(1));

// With custom permissions
$url = $disk->temporaryUrl('path/to/file.jpg', now()->addHours(1), [
    'permissions' => 'rw',  // read + write
]);
```

### Using as Default Disk

[](#using-as-default-disk)

To use Azure as your default filesystem disk, set in your `.env`:

```
FILESYSTEM_DISK=azure
```

Then you can use the Storage facade directly:

```
use Illuminate\Support\Facades\Storage;

Storage::put('file.txt', 'Contents');
$url = Storage::url('file.txt');
```

Private Files &amp; Temporary URLs
----------------------------------

[](#private-files--temporary-urls)

Azure Blob Storage controls access at the **container level**, not per-file like S3. This means all blobs in a container share the same access level. The recommended approach for serving private files is:

1. Keep your container **private** (the default)
2. Use `temporaryUrl()` to generate time-limited SAS-signed URLs for frontend display

### Visibility Model

[](#visibility-model)

Azure Access LevelFlysystem VisibilityDescriptionPrivate (no header)`private`No anonymous access. All requests require authentication or SAS token.Blob`public`Anonymous read access for individual blobs only.Container`public`Anonymous read and list access for all blobs.### Recommended Workflow

[](#recommended-workflow)

```
use Illuminate\Support\Facades\Storage;

$disk = Storage::disk('azure');

// Store a file (private by default)
$disk->put('invoices/invoice-001.pdf', $pdfContents);

// Generate a temporary URL for display (expires in 30 minutes)
$url = $disk->temporaryUrl('invoices/invoice-001.pdf', now()->addMinutes(30));

// Use in a Blade template
// Download Invoice
//
```

### Visibility Configuration

[](#visibility-configuration)

Add visibility settings to your disk config 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'),
    'visibility' => [
        'default' => env('AZURE_STORAGE_VISIBILITY', 'private'),
        'allow_set' => env('AZURE_STORAGE_ALLOW_SET_VISIBILITY', false),
    ],
],
```

- **`visibility.default`** — The fallback visibility when the container access level cannot be determined. Defaults to `private`.
- **`visibility.allow_set`** — When `false` (default), calling `setVisibility()` throws an exception with a helpful message. Set to `true` to allow changing the container's public access level via the Flysystem API.

```
// Check the container's visibility
$visibility = $disk->getVisibility('any-path'); // 'public' or 'private'

// Set visibility (only when allow_set is true)
$disk->setVisibility('any-path', 'private');
```

> **Note:** Since Azure controls access at the container level, the `$path` argument to `visibility()` and `setVisibility()` is ignored — the operation applies to the entire container.

SAS Token Generation
--------------------

[](#sas-token-generation)

For advanced SAS token generation, you can use the `SasTokenGenerator` directly:

```
use AliNauf\AzureStorage\Support\SasTokenGenerator;

$generator = new SasTokenGenerator(
    accountName: config('azure-storage.account_name'),
    accountKey: config('azure-storage.account_key'),
);

// Generate a blob SAS token
$sas = $generator->generateBlobSas(
    container: 'mycontainer',
    blob: 'path/to/file.jpg',
    expiry: now()->addHours(2),
    permissions: 'r',  // read only
);

// Generate a full signed URL
$url = $generator->generateSignedUrl(
    container: 'mycontainer',
    blob: 'path/to/file.jpg',
    expiry: now()->addHours(2),
);

// Generate a container-level SAS token
$containerSas = $generator->generateContainerSas(
    container: 'mycontainer',
    expiry: now()->addDays(7),
    permissions: 'rl',  // read + list
);
```

### SAS Permissions

[](#sas-permissions)

PermissionDescription`r`Read`w`Write`d`Delete`l`List`a`Add`c`CreateDirect Client Usage
-------------------

[](#direct-client-usage)

For advanced use cases, you can use the client directly:

```
use AliNauf\AzureStorage\AzureBlobStorageClient;

$client = new AzureBlobStorageClient(
    accountName: config('azure-storage.account_name'),
    accountKey: config('azure-storage.account_key'),
    container: config('azure-storage.container'),
);

// Upload a blob
$response = $client->putBlob('path/to/file.txt', 'Contents', 'text/plain');

// Get blob properties
$properties = $client->getBlobProperties('path/to/file.txt');
// Returns: ['content_length' => 123, 'content_type' => 'text/plain', 'last_modified' => 1234567890, 'etag' => '...']

// List blobs with prefix
$result = $client->listBlobs('path/to/', 100);
// Returns: ['blobs' => [...], 'next_marker' => '...']

// Copy a blob
$response = $client->copyBlob('source.txt', 'destination.txt');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on:

- Setting up the development environment
- Running tests
- Code style guidelines
- Submitting pull requests

Security
--------

[](#security)

If you discover a security vulnerability, please email directly instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ali Nauf](https://github.com/alinauf)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance81

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Total

2

Last Release

102d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d5ec1648de853ed7ece2e2e2f771e84855973721f11bba8c74010345516956c5?d=identicon)[alinauf](/maintainers/alinauf)

---

Top Contributors

[![alinauf](https://avatars.githubusercontent.com/u/17229359?v=4)](https://github.com/alinauf "alinauf (4 commits)")

---

Tags

filesystemFlysystemlaravelstorageazureblob

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alinauf-laravel-azure-storage/health.svg)

```
[![Health](https://phpackages.com/badges/alinauf-laravel-azure-storage/health.svg)](https://phpackages.com/packages/alinauf-laravel-azure-storage)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[sausin/laravel-ovh

OVH Object Storage driver for laravel

40153.5k](/packages/sausin-laravel-ovh)[zing/laravel-flysystem-obs

Flysystem Adapter for OBS

1211.2k](/packages/zing-laravel-flysystem-obs)[yoelpc4/laravel-cloudinary

Laravel Cloudinary filesystem cloud driver.

3343.0k](/packages/yoelpc4-laravel-cloudinary)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
