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:
- Log in to the Cloudflare dashboard ↗ and select your account and domain.
- Navigate to Rules > Cloud Connector.
- Select Microsoft Azure - Blob Storage as your cloud provider.
- 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 namedstatic-assets
, and files should be placed inside this folder. For example,https://<YOUR_HOSTNAME>/static-assets/style.css
will map tohttps://<BUCKET_NAME>.blob.core.windows.net/static-assets/style.css
.
- Subdomain-style URL: Set the hostname to
- (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. - Click Next and enter a descriptive name like “Serve static assets from Azure” in Cloud Connector name.
- Under If, select Custom filter expression and enter the following expression:
http.request.full_uri wildcard "https://<YOUR_HOSTNAME>/static-assets/*"
- Select Deploy to activate the rule.
This setup ensures that all traffic to https://<YOUR_HOSTNAME>/static-assets/*
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.