Secure Files - Azure

Secure File Storage App for Agility CMS using Azure Blob Storage

Description: This app enables you to securely store and manage files in Agility CMS using Azure Blob Storage. By integrating Azure Blob Storage, you can leverage its robust security features and scalability to handle your file storage needs efficiently. 

Setup Instructions:

  1. Create an Azure Blob Storage Account:
  2. Create a Container:
  3. Retrieve Access Keys:

Configuration in Agility CMS:

  1. In Agility CMS, navigate to the App section in settings and add the Secure Files - Azure app.
  2. Enter the connection string and access key values obtained from Azure Blob Storage in the Azure Portal.
  3. Save the configuration to enable the app.
  4. Add the Secure File custom field to a Content or Component Model.

Code Example

To deliver files to the frontend using a pre-signed SAS URL, you can use the following code snippet:

const { BlobServiceClient, generateBlobSASQueryParameters, StorageSharedKeyCredential } = require('@azure/storage-blob');

// Azure Storage account details
const accountName = 'your_account_name';
const accountKey = 'your_account_key';
const containerName = 'your_container_name';

//get the blob name from your agility content item
const blobName = 'your_blob_name'; 

// Create a shared key credential
const sharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey);

// Create a SAS token
const sasToken = generateBlobSASQueryParameters({
  containerName,
  blobName,
  permissions: 'r', // Read permission
  startsOn: new Date(),
  expiresOn: new Date(new Date().valueOf() + 3600 * 1000) // 1 hour expiry
}, sharedKeyCredential).toString();

// Construct the SAS URL
const sasUrl = `https://${accountName}.blob.core.windows.net/${containerName}/${blobName}?${sasToken}`;

console.log('SAS URL:', sasUrl);

// Use the SAS URL to deliver the file to the frontend
// Example: <a href={sasUrl} download>Download File</a>

This code generates a pre-signed SAS URL that allows secure access to a specific blob for a limited time. You can use this URL in your frontend to enable users to download files securely.