Provide storage for the public website
Source: Dev.to
Objective
Design and implement a secure, scalable, and reliable storage solution for public website assets, ensuring high availability and optimal performance for users worldwide.
Create a storage account
- In the Azure portal, search for Storage accounts and select + Create.
- For Resource group, choose Create new, give it a name (e.g.,
publicwebsiterg), and click OK. - Fill in the required fields for the storage account name, then click Review + create and Create.
- Wait for deployment to complete, then select Go to resource.
Configure redundancy
- In the storage account, go to Data management → Redundancy.
- Ensure Read-access Geo-redundant storage (RA‑GRS) is selected.
- Review the primary and secondary location information.
Enable anonymous blob access
- In Settings → Configuration, set Allow blob anonymous access to Enabled and click Save.
Create a public container
- In Data storage → Containers, click + Container.
- Name the container
public. - Click Create.
- Select the newly created container, then on the Overview blade choose Change access level.
- Set Public access level to Blob (anonymous read access for blobs only) and click OK.
Upload and test files
- Open the
publiccontainer and click Upload. - Browse to a file (e.g., a small image or text file) and click Upload.
- Refresh the page to confirm the file appears.
- Select the uploaded file, copy its URL from the Overview tab, and paste it into a new browser tab.
- If the file is an image, it should display in the browser.
Configure soft delete
- In the storage account Overview, go to Properties → Blob service.
- Select Blob soft delete.
- Check Enable soft delete for blobs.
- Set Keep deleted blobs for (days) to
21. - (Optional) Enable soft delete for containers.
- Click Save.
Restore a deleted blob
- In the container, select a file and click Delete, then confirm.
- On the container Overview page, toggle Show deleted blobs (right of the search box).
- Locate the deleted file, click the ellipsis (…) on the far right, and choose Undelete.
- Refresh the container to verify the file has been restored.
Configure blob versioning
- In the storage account Overview, go to Properties → Blob service.
- Select Versioning.
- Check Enable versioning for blobs.
- Choose whether to keep all versions or delete older versions after a certain period.
- Click Save.
Test versioning
- Upload a new version of an existing file in the
publiccontainer (this overwrites the current blob). - Use Show deleted blobs (or version view) to see previous versions and experiment with restoring them.