How to store to Azure Blob Storage

The following documentation is for SuiteCRM Version 8.9.0+

How to store to Azure Blob Storage

In this example we will configure the private.documents.storage to use Azure Blob Storage for file storage.

Prerequisites

  • Azure Blob Storage account and container created.

  • Azure connection string available.

  • SuiteCRM backend with VichUploader and Flysystem configured.

1. Define Azure Blob Instance

Edit your .env.local (or appropriate environment file) and add your Azure Blob instance configuration:

AZURE_BLOB_INSTANCES='{
  "main": {
    "connection_string": "DefaultEndpointsProtocol=https;AccountName=YOUR_ACCOUNT;AccountKey=YOUR_KEY;EndpointSuffix=core.windows.net"
  }
}'

2. Configure Flysystem Storage

Set the MEDIA_FLY_SYSTEM_STORAGES variable to use Azure for private.documents.storage:

Note: on the following example main from azure.blob.client.main in the client option should match the key defined in AZURE_BLOB_INSTANCES.

MEDIA_FLY_SYSTEM_STORAGES='{
  "private.documents.storage": {
    "adapter": "azure",
    "options": {
      "client": "azure.blob.client.main",
      "container": "YOUR_CONTAINER_NAME"
    }
  }
}'
  • Replace YOUR_CONTAINER_NAME with your Azure Blob container name.

3. Clear Cache and Restart

After updating environment variables, clear the Symfony cache and restart your application:

php bin/console cache:clear

4. Verify Configuration

Uploads for private.documents.storage will now use Azure Blob Storage. You can test by uploading a document and confirming it appears in your Azure container.

Notes

  • The default storage for private.documents.storage is local. The above steps override it to use Azure.

  • You can configure other storages similarly by updating their respective keys in MEDIA_FLY_SYSTEM_STORAGES.

  • For production, use secrets management for sensitive values.

Using Symfony Secrets

Symfony secrets allow you to securely store sensitive configuration values (like API keys, passwords, etc.) outside of your codebase. Instead of putting secrets in .env files, you use the Symfony secrets vault, which encrypts values and keeps them out of version control.

You can reference Symfony secrets in these environment variables for sensitive data (like access keys or connection strings).

Example using secrets:

AZURE_BLOB_INSTANCES='{
  "main": {
    "connection_string": "%env(AZURE_BLOB_CONNECTION_STRING)%",
  }
}'

To set a secret:

php bin/console secrets:set AZURE_BLOB_CONNECTION_STRING

Then reference the secret in your JSON config using %env(SECRET_NAME)%.

Note
When using secrets in JSON, always wrap the reference in double quotes.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.