Skip to main content

Quickstart

Configure The Blob Client

Declare a BlobServiceClient service. This example creates one from a connection string:

# config/services.yaml
services:
azure_blob_service_client:
class: AzureOss\Storage\Blob\BlobServiceClient
factory: ['AzureOss\Storage\Blob\BlobServiceClient', 'fromConnectionString']
arguments:
- '%env(AZURE_STORAGE_CONNECTION_STRING)%'

Configure The Filesystem

Reference the service from a Flysystem storage that uses the azure_oss adapter:

# config/packages/flysystem.yaml
flysystem:
storages:
default.storage:
azure_oss:
client: azure_blob_service_client
container: '%env(AZURE_STORAGE_CONTAINER)%'
# Optional:
# prefix: 'optional/path/prefix'
# mime_type_detector: 'my.custom.mime_type_detector'
# visibility_handling: throw # or 'ignore'
# public_container: false
visibility: public

The client value is the Symfony service id, not an Azure connection string.

Use The Filesystem

The Flysystem bundle exposes the configured storage for autowiring:

<?php

use League\Flysystem\FilesystemOperator;

final class MyService
{
public function __construct(
private readonly FilesystemOperator $defaultStorage,
) {
}
}

The argument name corresponds to the storage name: default.storage becomes $defaultStorage.

Configuration Reference

OptionRequiredDefaultDescription
clientyesService id of a configured AzureOss\Storage\Blob\BlobServiceClient.
containeryesAzure Blob Storage container name.
prefixno''Path prefix prepended to every blob name.
mime_type_detectornonullService id of a League\MimeTypeDetection\MimeTypeDetector. Defaults to the adapter's FinfoMimeTypeDetector.
visibility_handlingnothrowBehavior when setVisibility() is called. Use throw or ignore; Azure has no per-blob ACL.
public_containernofalseWhether the container allows public access. This affects URL generation.

For supported filesystem operations and Azure-specific behavior, continue to the Flysystem quickstart.