MicrosoftLearning/Secure-storage-for-Azure-Files-and-Azure-Blob-Storage
Published: 2024-06-07 18:01:50

Create a storage account to support the public website.

In the portal, search for and select Storage accounts.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7f2rfc4s6brh60wixwz.png)

Select + Create.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lm4b8lkvlc8636o69kx6.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0swe02lfxgzsm0lukbrb.png)

Set the Storage account name to _publicwebsite_. Make sure the storage account name is unique by adding an identifier.
Take the defaults for other settings.
Select Review and then Create.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4ema6dc7sfp0hj4hrz6.png)

Wait for the storage account to deploy, and then select Go to resource.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dwkq5rnjpd9r1bccv9n.png)

In the storage account, in the Data management section, select the Redundancy blade.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vv0r4ajormlru9tugd3z.png)

Ensure Read-access Geo-redundant storage is selected.
Review the primary and secondary location information.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2x125wo10j1m2f4pa08g.png)

In the storage account, in the Settings section, select the Configuration blade.
Ensure the Allow blob anonymous access setting is Enabled.
Be sure to Save your changes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8qismka37n9jw0snp10.png)

Create a blob storage container with anonymous read access
The public website has various images and documents. 
Create a blob storage container for the content.
In your storage account, in the Data storage section, select the Containers blade.
Select + Container.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2r5tjix3410a60bytnap.png)

Ensure the Name of the container is public.
Select Create.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bigpsq7ho9dloy3b63h.png)

Customers should be able to view the images without being authenticated. Configure anonymous read access for the public container blobs.
Select your public container.
On the Overview blade, select Change access level.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/49dw4mquwbol88ogtmw4.png)


Ensure the Public access level is Blob (anonymous read access for blobs only).
Select OK.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk5637v8qmlfgdy6zvc5.png)

_Practice uploading files and testing access._
For testing, upload a file to the public container. The type of file doesn’t matter. A small image or text file is a good choice.
Ensure you are viewing your container.
Select Upload.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6dluc126z7sk6dgxxqq.png)

Browse to files and select a file. Browse to a file of your choice.
Select Upload.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91culsslzqr78vp37nuq.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgnkc8nwnndtsp80anzr.png)


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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi2kno2t3je8rjg5ti2f.png)

On the Overview tab, copy the URL.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mlvhp636hjo39lpq6nri.png)

Paste the URL into a new browser tab.
If you have uploaded an image file it will display in the browser. Other file types should be downloaded.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrykbx2cll249ykp2g6v.png)

Configure soft delete
It’s important that the website documents can be restored if they’re deleted. Configure blob soft delete for 21 days. 
Go to the Overview blade of the storage account.
On the Properties page, locate the Blob service section.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t08csr7dumg59ix2zsui.png)


Select the Blob soft delete setting.
Ensure the Enable soft delete for blobs is checked.
Change the Keep deleted blobs for (in days setting is 21.
Notice you can also Enable soft delete for containers.
Don’t forget to Save your changes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gt3oxv4tnhf1ltidc2wj.png)

If something gets deleted, you need to practice using soft delete to restore the files.
Navigate to your container where you uploaded a file.
Select the file you uploaded and then select Delete
Select OK to confirm deleting the file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jfb7ilmbh3a03b8wgpgj.png)

On the container Overview page, toggle the slider Show deleted blobs. This toggle is to the right of the search box.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/am2cuiv8o93jxjlnijy8.png)

Select your deleted file, and use the ellipses on the far right, to Undelete the file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pec7s97c1s54kp7xizjx.png)

Refresh the container and confirm the file has been restored.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlqpmhcvrk3v10o9qthk.png)

Configure blob versioning
It’s important to keep track of the different website product document versions. 
Go to the Overview blade of the storage account.
In the Properties section, locate the Blob service section.
Select the Versioning setting.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4jlhsa3lr1rorbrv8qj.png)

Ensure the Enable versioning for blobs checkbox is checked.
Notice your options to keep all versions or delete versions after.
Don’t forget to Save your changes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5inztj4b6ufsxkpzbvr.png)

Upload another version of your container file. This overwrites your existing file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0w4kinbefnv87hg38mwr.png)

Your previous file version is listed on Show deleted blobs page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i89y6p5c553y000wtl7e.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u5dfih9045dvvxofmopw.png)