Skip to content

Serve /static-assets from Azure Blob Storage

Route requests with a URI path starting with /static-assets to an Azure Blob Storage container using Cloud Connector.

To serve static assets from an Azure Blob Storage container:

  1. Log in to the Cloudflare dashboard and select your account and domain.
  2. Navigate to Rules > Cloud Connector.
  3. Select Microsoft Azure - Blob Storage as your cloud provider.
  4. Enter the bucket URL. Here’s how to structure it:
    • Subdomain-style URL: Set the hostname to <BUCKET_NAME>.blob.core.windows.net. In this case, your bucket should include a folder named static-assets, and files should be placed inside this folder. For example, https://<YOUR_HOSTNAME>/static-assets/style.css will map to https://<BUCKET_NAME>.blob.core.windows.net/static-assets/style.css.
  5. (Optional) Use the Rewrite URL feature of Transform Rules to adjust the URL structure. For example, you can create a URL rewrite that changes /static-assets to /my-pages-project/static-assets to match the file structure of your object storage bucket.
  6. Click Next and enter a descriptive name like Serve static assets from Azure in Cloud Connector name.
  7. Under If, select Custom filter expression and enter the following expression: http.request.full_uri wildcard "http*://<YOUR_HOSTNAME>/static-assets/*"
  8. Select Deploy to activate the rule.

This setup ensures that all traffic matching http*://<YOUR_HOSTNAME>/static-assets/* (HTTPS and HTTP requests) is served from your Azure Blob Storage container. Make sure to replace <YOUR_HOSTNAME> with your actual hostname and adjust the example paths according to your setup.