Zum Inhalt springen

How to Create a Highly Available Azure Storage Account with Public Access, Soft Delete, and Blob Versioning for Website Hosting

Hosting a static website on Azure Blob Storage offers a scalable and budget-friendly solution. Enabling public access, soft delete, and blob versioning ensures your site is accessible to users, protected against accidental deletions, and maintains a history of file changes.

        Architecture diagram

 Architecture diagram

This guide will show you step by step how to:

-Create an Azure Blob Storage account with high availability that will continue to work and keep data accessible, even if some hardware or entire regions fail.

-Allow anonymous public access so that anyone can view your files without needing to log in.

-Create a blob storage container to store your website files and make them available online.

-Enable soft delete, which lets you recover files if they are accidentally deleted.

-Enable blob versioning, so you can go back to earlier versions of a file if needed.

These are the steps to follow:

Create a storage account with high availability.
Step 1. Log in to the Azure Portal.

Log in to the Azure Portal.<br>

Step 2. In the portal, search for and select Storage accounts.

In the portal, search for and select Storage accounts.<br>

Step 3. Select + Create.

Select + Create

Step 4. For resource group select new. Give your resource group a name and select OK

For resource group select new

Give your resource group a name and select OK

Step 5. Set the Storage account name to publicwebsite.

Set the Storage account name to publicwebsite

Step 6. Select Review and then Create.

Select Review and then Create

Step 7. Create and Wait for the storage account to deploy.

Create

Step 8. Go to storage account, in the Data management section, select the Redundancy blade.

Data management and Redundancy

Step 9. Ensure Read-access Geo-redundant storage is selected.

Read-access Geo-redundant storage

Step 10. Review the primary and secondary location information.

Location

Step 11. Go to storage account, in the Settings section, select the Configuration blade.

setting and configuration

Step 12. Ensure the Allow blob anonymous access setting is Enabled and make sure to save the changes.

Enable and save

Create a blob storage container with anonymous read access

Step 1. Go to storage account, in the Data storage section, select the Containers blade.

Data storage and containers

Step 2. Select + add Container.

Add container

Step 3. Ensure the Name of the container is public and select create.

Ensure the Name of the container is public and select create

Step 4. Select your public container.

Select your public container

Step 5. On the Overview blade, select Change access level.

 Change access level

Step 6. Ensure the Public access level is Blob (anonymous read access for blobs only).

anonymous read access for blobs only

Step 7. Select OK.

select okay

Practice uploading files and testing access.

Step 1. For testing, upload a file to the public container.
A. Ensure you are viewing your container.

Ensure you are viewing your container

B. Select Upload.

Select Upload

C. Browse to files.

 Browse to files

D. Select file and upload.

Select file and upload

E. Close the upload window, Refresh the page and ensure your file was uploaded.

Uploaded file

Step 2. Determine the URL for your uploaded file. Open a browser and test the URL.
A. Select your uploaded file.

Select your uploaded file

B. On the Overview tab, copy the URL.

Copy the URL

C. Paste the URL into a new browser tab.

Paste the URL

D. If you have uploaded an image file it will display in the browser.

URL display

Enabling a blob soft delete with a 21-day retention to allow file recovery.

Step 1. Go to the Overview blade of the storage account.

Go to the Overview blade of the storage account

Step 2. On the Properties page, locate the Blob service section.

On the Properties page, locate the Blob service section

Step 3. Select the Blob soft delete setting.

Select the Blob soft delete setting

Step 4. Ensure the Enable soft delete for blobs is checked.

Ensure the Enable soft delete for blobs is checked

Step 5. Change the Keep deleted blobs for (in days setting is 21).

Change the Keep deleted blobs for in days setting is 21

Step 6. Notice you can also Enable soft delete for containers.

Notice you can also Enable soft delete for containers

Step 7. Select save.

Select save

Practice using soft delete to restore deleted files.

How to delete file from the container.
Step 1. Navigate to your container where you uploaded a file.

Navigate to your container where you uploaded a file

Step 2. Select the file you uploaded and then select Delete.

select file and delete

Step 3. Select delete to confirm deleting the file.

Select delete to confirm deleting the file

You can see the file is deleted.

File deleted

How to restore deleted files.
Step 1. On the container Overview page, go to Show only active blobs on the right side of your screen, click the drop down button and the select show active and deleted blobs.

toggle the slider Show deleted blobs

Step 2. Select your deleted file.

Select your deleted file

Step 3. Use the ellipses on the far right of the selected deleted file, click Undelete to delete the file.

click Undelete to delete the file.

Step 4. Refresh the container and confirm the file has been restored.

Refresh the container and confirm the file has been restored

Enable blob versioning.

Step 1. Go to the Overview blade of the storage account.

Go to the Overview blade of the storage account

Step 2. In the Properties section, locate the Blob service section.

On the Properties page, locate the Blob service section

Step 3. Select the Versioning setting.

Select the Versioning setting

Step 4. Ensure the Enable versioning for blobs checkbox is checked.

Ensure the Enable versioning for blobs checkbox is checked

Step 5. Notice your options to keep all versions or delete versions after, and save.

Notice your options to keep all versions or delete versions after, and save

Lets try restoring Previous Versions of Blobs in Azure Storage.

Step 1. Upload another version of your container file with the same name but different content.

Upload another version of your container file

Upload another version of your container file

Step 2. Notice that your newly uploaded file overwrites your already existing file.

newly uploaded file overwrites your already existing file

Conclusion.
Configuring a highly available Azure Storage account with public access, soft delete, and blob versioning creates a secure and dependable platform for hosting static websites. Public access makes your content easily accessible to users, while soft delete and versioning protect against unintended changes or deletions. By implementing these features, you ensure fast, global content delivery and robust data protection, keeping your website consistently available, resilient, and easily recoverable.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert