Introduction
Part 1: https://www.codeproject.com/Articles/1273552/Azure-Storage-Account-Part-1-What-is-Blob
Part 2: https://www.codeproject.com/Articles/1273613/Azure-Storage-Account-Part-2-Upload-Files-in-Blob
In our previous post, we have seen how to Deploy your site to Azure App service from Visual Studio, and after that, we will find out how to upload the contents of your site in Azure blob storage account.
In this module, we will learn:
- What is Azure Storage Account & how to access it
- Create your very own storage account in Azure
- Access keys of Storage Account
- Container & Blob
- Manage your blobs from Azure portal
So, let’s start.
1. What Is Azure Storage Account & How to Access It
Azure storage is like a container where user can store Azure storage data objects. Azure storage data objects holds blobs, files, queues, tables, and disks. You might notice that whenever you are creating any app service, a new storage account has been created by the same or related name under the same resource group, it is holding the disks for the App service. Like this, you can create your own storage account to store the data (files or blob).
Basic Features of Azure Storage Accounts
- It is highly available and durable
- Encrypted & secure
- Scalable
- Accessible from anywhere in the world
To access the storage account, go to your Azure portal (https://portal.azure.com). In the search bar, search for storage account or you may find the link on the left sidebar nav. Click on the link to navigate to your storage account page.
Here, you can find all the storage accounts that have been created under your subscription.
Click on each storage account to access the same. Or you can create your own by clicking on the (+ Add) button on the top left side of the blade.
Generally, There Are Three Types of Storage Accounts in Azure
- General-purpose v2 accounts
- General-purpose v1 accounts
- Blob storage accounts
You will find these options while creating a new storage account from the portal.
Types | Supported Service | Performance Tiers | Access Tiers | Replication options |
General-purpose V2 | Blob, File, Queue, Table, and Disk | Standard, Premium | Hot, Cool, Archive | LRS, ZRS, GRS, RA-GRS |
General-purpose V1 | Blob, File, Queue, Table, and Disk | Standard, Premium | N/A | LRS, GRS, RA-GRS |
Blob storage | Blobs | Standard | Hot, Cool, Archive | LRS, GRS, RA-GRS |
Purpose of Blob Storage
- To store files for distributed system
- To stream audio and video files
- To store data for back and restore, which will take place in time of recovery, and archiving
- To access data for Azure based apps (Azure Logic Apps)
Key Things to Be Remembered
- Storage account name should be within 3-24 characters and it can hold only numbers and lowercase characters only.
- Name of your storage account should be unique. Two storage accounts with the same name in whole Azure cannot be created.
2. Create Your Own Storage Account in Azure Portal
To create a new storage account, click on the (+ Add) button on the storage account blade as shown in the last image. This will lead you to the creation blade of an Azure storage account. Here, we will create a new storage account of type blob.
Kindly refer to the following steps to create your storage account.
- In the creation blade, first choose your subscription and resource group, under which your storage account will be created.
- Provide a unique storage name.
- Choose your location from location drop down.
- Choose Blob from the Account Kind. Once you choose “Blob storage” from the drop down automatically “Premium” will be disabled, as Azure does not support premium for “Blob storage”.
- Set your replication and access tier and click on the “Review + Create” button underneath.
It will take a few minutes to create a new storage account. After creation, you can find the created account name in the storage account blade.
Now click on that to access the account.
3. Access Keys of Storage Account
To access your storage accounts from outside, we need connections strings, which are provided by Azure for individual storage account. To access these connection stings, go to your storage account and click on the “Access Keys” from the left side menu. Or you can search from the top search bar.
There, you will find your storage account name and couple of key (512 bit)/connection string combination. Use the refresh buttons to regenerate the keys and connection strings. Regenerating your access keys will not interrupt your application. It's Microsoft’s recommendation to change the keys regularly.
Use these connection strings to access your storage account from outside.
4. Container & Blob
In your storage account, files are stored as blob and they are grouped in a container. Account stores containers and container stores blobs.
5. Manage Your Blobs From Azure Portal
Within the “Blob Service” header, you will find the option called “Blob”. Using this, you can manage your blobs from Azure portal. On the first page, i.e., the container page, you can add, edit or delete any container of your choice.
Click the (+ Container) button to add a new container. Put the container name and choose the access of container you want. Apart from private, you can directly access the blob, but in most of the scenarios, we choose private blobs, which is not accessible directly. We have to get it using the key provided in “Access Key” section.
After creating a container, you can view the list of containers in a grid. Click on the container name to access it.
Here in the blob blade, use “Upload” button to upload any file into this container. A blob can be up to 195 GB in total size. After uploading the file, you can manage it from the same page.
Relative Path
Acquire lease: You might find an option called “Acquire lease” on the top of the blobs grid. If you select the Acquire lease for a particular blob, you cannot edit the blob until you break it. But you can edit with the help of Lease Id, which will be populated while you are enabling the Acquire lease for the file.
Generate SAS: To download the private blob externally, we have to generate a SAS token. You can set the validity of the generated SAS token. By default, it is 8 Hr. You can also set the permission to Read, Create, Write & Delete.
Share the SAS URL to the users to view the file.
In the next session, we will cover how to upload or download a blob from C# using Visual Studio.
Part 2: https://www.codeproject.com/Articles/1273613/Azure-Storage-Account-Part-2-Upload-Files-in-Blob
CodeProject