How to Store Private Files in Azure Blob Storage
Azure Blob Storage is a great way to host both public website content and private company files. In this post, I’ll guide you through:
- Adding safety features like soft delete and versioning
- Creating a private storage account for sensitive documents
- Giving temporary access using SAS (Shared Access Signatures)
- Using lifecycle rules to manage storage costs
- Setting up replication to back up files from one storage account to another
Let’s dive in.
☁️ Part 1: Set Up a Public Storage Account
🔧 Step 1: Create the Storage Account
- Log in to the Azure Portal.
- Search for "Storage accounts" and click + Create.
- Create a new resource group (e.g.,
storage-rg
). - Name your account something like
privatewebsitemyezekiel
(the name must be globally unique). - Click Review + Create, then Create.
🔐 Part 2: Store Internal Documents in a Private Container
🔧 Step 1: Create the Private Storage Account
- Create another storage account (e.g.,
privatewebsitemyezekiel
) in the same resource group. - Click Review + Create, then Create.
🌐 Step 2: Enable Geo-Redundant Storage (GRS Only)
- In the storage account, go to Redundancy.
- Select Geo-redundant storage (GRS) — no read access needed.
- Save the setting.
📁 Step 3: Create a Private Container
- Go to Containers → click + Container.
- Name it
private
. - Set Public access level to Private (no anonymous access).
- Click Create.
🚫 Step 4: Test That the File Is Not Public
- Upload a small file.
- Copy the Blob URL and try to open it in a browser — it should not open.
🔐 Step 5: Grant Temporary Access with SAS
- Click on the uploaded file → go to the Generate SAS tab.
- Grant Read permission.
- Set an expiry of 24 hours.
- Click Generate SAS token and URL.
- Open the URL in a browser to test.
✅ The file should now load only with this link.
🧊 Step 6: Use Lifecycle Rules to Save Costs
- Go to Lifecycle management.
- Click Add rule.
- Name it
movetocool
. - Apply to all blobs → set rule to "Last modified more than 30 days" → Move to cool tier.
- Save the rule.
🔁 Step 7: Backup Public Files with Replication
- In the private storage account, create a new container named
backup
. - Go to the public storage account → Object replication.
- Create a replication rule:
- Destination account: private storage
-
Source container:
public
-
Destination container:
backup
- Upload a file to
public
, and it will appear inbackup
after a few minutes.
- Upload a file to
✅ Summary
Here’s what we’ve accomplished:
Feature | Public Account | Private Account |
---|---|---|
High Availability | RA-GRS | GRS |
Anonymous Access | Enabled | Disabled |
Soft Delete | Enabled (21 days) | Optional |
Blob Versioning | Enabled | Optional |
SAS Access | Not needed | Used for secure sharing |
Lifecycle Management | Move to cool after 30 days | Same |
Replication | From public to backup | As destination only |
This setup ensures that public content is easily accessible and private files are secure, while still keeping your storage cost-effective and recoverable.
Top comments (0)