Quickstart
Prerequisites
config/filesystems.phpcontains anazuredisk usingdriver => azure-storage-blob
Example .env values:
AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=...;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net"
AZURE_STORAGE_CONTAINER="quickstart"
Basic Usage
use Illuminate\Support\Facades\Storage;
$disk = Storage::disk('azure');
// Write
$disk->put('docs/hello.txt', 'Hello from Laravel');
// Read
$content = $disk->get('docs/hello.txt');
// Exists
$exists = $disk->exists('docs/hello.txt');
// Copy / move
$disk->copy('docs/hello.txt', 'docs/hello-copy.txt');
$disk->move('docs/hello-copy.txt', 'docs/hello-moved.txt');
// List
$files = $disk->allFiles('docs');
// Delete
$disk->delete('docs/hello-moved.txt');
URLs
use Illuminate\Support\Facades\Storage;
$disk = Storage::disk('azure');
$url = $disk->url('images/logo.png'); // SAS URL by default
If your container is public, set is_public_container => true in disk config to return direct blob URLs without SAS query parameters.
Temporary URL (SAS):
$temporaryUrl = Storage::disk('azure')->temporaryUrl(
'exports/report.csv',
now()->addMinutes(15)
);
Temporary upload URL:
$upload = Storage::disk('azure')->temporaryUploadUrl(
'uploads/photo.jpg',
now()->addMinutes(10),
['content-type' => 'image/jpeg']
);
// $upload['url'] contains the signed URL
// $upload['headers'] contains required request headers
Upload Options (HTTP Headers)
You can pass Flysystem write options as the third argument to put():
$css = 'body { color: #0f172a; }';
Storage::disk('azure')->put('assets/app.css', $css, [
'httpHeaders' => [
'cacheControl' => 'public, max-age=31536000',
'contentType' => 'text/css',
],
]);
Notes
- When using Microsoft Entra ID credentials, the disk cannot generate SAS URLs (
providesTemporaryUrls()returnsfalse). - Optional
prefix(orroot) in disk config scopes all paths to a subfolder-like prefix in the container.