PHPackages                             hwkdo/azure-storage-laravel - 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. hwkdo/azure-storage-laravel

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

hwkdo/azure-storage-laravel
===========================

This is my package azure-storage-laravel

v0.2(8mo ago)0225MITPHPPHP ^8.3CI failing

Since Oct 10Pushed 8mo agoCompare

[ Source](https://github.com/hwkdo/azure-storage-laravel)[ Packagist](https://packagist.org/packages/hwkdo/azure-storage-laravel)[ Docs](https://github.com/hwkdo/azure-storage-laravel)[ GitHub Sponsors](https://github.com/hwkdo)[ RSS](/packages/hwkdo-azure-storage-laravel/feed)WikiDiscussions main Synced 3w ago

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

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

[](#azure-storage-laravel)

A Laravel package for managing Azure Blob Storage with OAuth token authentication. Upload, list, and delete files from Azure Blob Storage with automatic token management and support for multiple connections.

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

[](#installation)

You can install the package via composer:

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

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="azure-storage-laravel-migrations"
php artisan migrate
```

You can publish the config file with:

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

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

[](#configuration)

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

```
# Azure Blob Storage
AZURE_STORAGE_TENANT_ID=your-tenant-id
AZURE_STORAGE_CLIENT_ID=your-client-id
AZURE_STORAGE_CLIENT_SECRET=your-client-secret
AZURE_STORAGE_ACCOUNT_NAME=your-storage-account-name
AZURE_STORAGE_CONTAINER=your-container-name

# Azure AI Search (optional - only if using indexer features)
AZURE_SEARCH_SERVICE_NAME=your-search-service-name
AZURE_SEARCH_ADMIN_API_KEY=your-admin-api-key
AZURE_SEARCH_INDEX_NAME=your-index-name
AZURE_SEARCH_API_VERSION=2024-07-01
```

### Azure Setup

[](#azure-setup)

1. Create an App Registration in Azure Portal
2. Create a Client Secret for the app
3. Assign the **Storage Blob Data Contributor** role to your app on the Storage Account
4. The package will automatically manage OAuth tokens with scope `https://storage.azure.com/.default`

### Multiple Connections

[](#multiple-connections)

You can configure multiple Azure Storage connections in `config/azure-storage-laravel.php`:

```
'connections' => [
    'azure' => [
        'tenant_id' => env('AZURE_STORAGE_TENANT_ID'),
        'client_id' => env('AZURE_STORAGE_CLIENT_ID'),
        'client_secret' => env('AZURE_STORAGE_CLIENT_SECRET'),
        'account_name' => env('AZURE_STORAGE_ACCOUNT_NAME'),
        'container' => env('AZURE_STORAGE_CONTAINER'),
    ],
    'backup' => [
        'tenant_id' => env('AZURE_STORAGE_BACKUP_TENANT_ID'),
        'client_id' => env('AZURE_STORAGE_BACKUP_CLIENT_ID'),
        'client_secret' => env('AZURE_STORAGE_BACKUP_CLIENT_SECRET'),
        'account_name' => env('AZURE_STORAGE_BACKUP_ACCOUNT_NAME'),
        'container' => env('AZURE_STORAGE_BACKUP_CONTAINER'),
    ],
],
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use Hwkdo\AzureStorageLaravel\Facades\AzureStorageLaravel;

// Upload a file
$result = AzureStorageLaravel::uploadFile('document.pdf', storage_path('app/document.pdf'));
// Returns: ['success' => true, 'url' => '...', 'blob_name' => 'document.pdf', 'size' => 12345, ...]

// List all blobs
$blobs = AzureStorageLaravel::listBlobs();
// Returns: [['name' => 'file.pdf', 'url' => '...', 'size' => 12345, 'content_type' => 'application/pdf', ...], ...]

// List blobs with prefix
$blobs = AzureStorageLaravel::listBlobs('uploads/2024/');

// Delete a blob
$deleted = AzureStorageLaravel::deleteBlob('document.pdf');
// Returns: true
```

### Using Multiple Connections

[](#using-multiple-connections)

```
// Use a specific connection
$result = AzureStorageLaravel::connection('backup')->uploadFile('backup.zip', storage_path('app/backup.zip'));

// List blobs from backup connection
$blobs = AzureStorageLaravel::connection('backup')->listBlobs();
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Hwkdo\AzureStorageLaravel\AzureStorageLaravel;

class FileController extends Controller
{
    public function upload(Request $request, AzureStorageLaravel $storage)
    {
        $file = $request->file('document');
        $tmpPath = $file->store('temp');

        try {
            $result = $storage->uploadFile(
                $file->getClientOriginalName(),
                storage_path('app/' . $tmpPath)
            );

            unlink(storage_path('app/' . $tmpPath));

            return response()->json($result);
        } catch (\Exception $e) {
            return response()->json(['error' => $e->getMessage()], 500);
        }
    }
}
```

Azure AI Search Indexer Operations
----------------------------------

[](#azure-ai-search-indexer-operations)

The package also supports Azure AI Search indexer management:

### Run an Indexer

[](#run-an-indexer)

```
use Hwkdo\AzureStorageLaravel\Facades\AzureStorageLaravel;

// Trigger an indexer to run (using config default)
AzureStorageLaravel::runIndexer();
// Returns: true (202 Accepted - indexer run queued)

// Or specify a specific indexer name
AzureStorageLaravel::runIndexer('my-indexer-name');
```

### Get Indexer Status

[](#get-indexer-status)

```
// Check the status of default indexer
$status = AzureStorageLaravel::getIndexerStatus();

// Or check a specific indexer
$status = AzureStorageLaravel::getIndexerStatus('my-indexer-name');

// Returns array with status information:
// [
//     'status' => 'running',
//     'lastResult' => [...],
//     'executionHistory' => [...],
// ]
```

### Reset an Indexer

[](#reset-an-indexer)

```
// Reset the default indexer (clears execution history)
AzureStorageLaravel::resetIndexer();
// Returns: true

// Or reset a specific indexer
AzureStorageLaravel::resetIndexer('my-indexer-name');
```

### List All Indexers

[](#list-all-indexers)

```
// Get list of all indexers in the search service
$indexers = AzureStorageLaravel::listIndexers();

// Returns array of indexers:
// [
//     ['name' => 'indexer1', 'dataSourceName' => '...', ...],
//     ['name' => 'indexer2', 'dataSourceName' => '...', ...],
// ]
```

### Example: Run Indexer After Upload

[](#example-run-indexer-after-upload)

```
use Hwkdo\AzureStorageLaravel\Facades\AzureStorageLaravel;

// Upload a file
$result = AzureStorageLaravel::uploadFile('document.pdf', storage_path('app/document.pdf'));

// Trigger the indexer to process the new file
if ($result['success']) {
    AzureStorageLaravel::runIndexer('document-indexer');
}
```

Features
--------

[](#features)

### Azure Blob Storage

[](#azure-blob-storage)

- **Automatic Token Management**: OAuth tokens are automatically fetched, cached, and refreshed
- **Multiple Connections**: Support for multiple Azure Storage accounts
- **Blob Name Sanitization**: Automatic sanitization of blob names (ASCII conversion, slugification)

### Azure AI Search

[](#azure-ai-search)

- **Indexer Management**: Run, reset, and monitor Azure AI Search indexers
- **Status Monitoring**: Check indexer execution status and history
- **List Operations**: View all configured indexers

### General

[](#general)

- **Laravel HTTP Client**: Uses Laravel's built-in HTTP client for all requests
- **Comprehensive Logging**: All operations are logged for debugging
- **Exception Handling**: Proper error handling with detailed error messages

API Reference
-------------

[](#api-reference)

### `listBlobs(?string $prefix = null): array`

[](#listblobsstring-prefix--null-array)

List all blobs in the configured container.

**Parameters:**

- `$prefix` (optional): Filter blobs by prefix

**Returns:** Array of blob information including name, url, size, content\_type, last\_modified

### `uploadFile(string $blobName, string $pathToFile): array`

[](#uploadfilestring-blobname-string-pathtofile-array)

Upload a file to Azure Blob Storage.

**Parameters:**

- `$blobName`: The name for the blob (will be sanitized)
- `$pathToFile`: Local path to the file to upload

**Returns:** Array with success, url, blob\_name, container, size, content\_type

### `deleteBlob(string $blobName): bool`

[](#deleteblobstring-blobname-bool)

Delete a blob from Azure Blob Storage.

**Parameters:**

- `$blobName`: Name of the blob to delete

**Returns:** `true` on success

### `connection(string $connection): self`

[](#connectionstring-connection-self)

Switch to a different connection.

**Parameters:**

- `$connection`: Name of the connection from config

**Returns:** New instance for the specified connection

### `runIndexer(?string $indexerName = null): bool`

[](#runindexerstring-indexername--null-bool)

Run an Azure AI Search indexer.

**Parameters:**

- `$indexerName` (optional): Name of the indexer to run. Uses `ai_search.index_name` from config if not provided.

**Returns:** `true` on success (202 Accepted)

### `getIndexerStatus(?string $indexerName = null): array`

[](#getindexerstatusstring-indexername--null-array)

Get the status and execution history of an indexer.

**Parameters:**

- `$indexerName` (optional): Name of the indexer. Uses `ai_search.index_name` from config if not provided.

**Returns:** Array with status, lastResult, executionHistory

### `resetIndexer(?string $indexerName = null): bool`

[](#resetindexerstring-indexername--null-bool)

Reset an indexer, clearing its execution history.

**Parameters:**

- `$indexerName` (optional): Name of the indexer to reset. Uses `ai_search.index_name` from config if not provided.

**Returns:** `true` on success

### `listIndexers(): array`

[](#listindexers-array)

List all indexers in the Azure AI Search service.

**Returns:** Array of indexer configurations

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [hwkdo](https://github.com/hwkdo)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance59

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~0 days

Total

2

Last Release

260d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72b6d361b5e84bd3dfecc691278039a815c252495b4624dd6f50caa27ff02655?d=identicon)[hwkdo](/maintainers/hwkdo)

---

Top Contributors

[![aleex1848](https://avatars.githubusercontent.com/u/17452861?v=4)](https://github.com/aleex1848 "aleex1848 (2 commits)")[![hwkdo](https://avatars.githubusercontent.com/u/181193575?v=4)](https://github.com/hwkdo "hwkdo (1 commits)")

---

Tags

laravelhwkdoazure-storage-laravel

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

43140.3k](/packages/harris21-laravel-fuse)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24855.3k](/packages/vormkracht10-laravel-mails)[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

18476.4k](/packages/lunarstorm-laravel-ddd)

PHPackages © 2026

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