Azure Blob Storage
This is Microsoft’s object storage solution for the cloud. Primarily, Blob storage is designed to store massive amounts of unstructured data, such as text or binary data.
Uses of Blob storage:
- It serves images or documents directly to a browser.
- It stores files for distributed access.
- Video and audio can be streamed using blob storage.
- It makes writing to log files easier.
- It stores data for backup, restoration, disaster recovery and archiving.
- It stores data for analysis by an on-premises or Azure-hosted service.
Azure Blob Storage is fundamental to all of Microsoft Azure because many other Azure services will store data in a storage account, in Blob Storage, and act on that data. And every blob must be in a container.
Container
A container is more like a folder containing different blobs. At the container level, we can define security policies and assign them to the container, which will cascade to all blobs in the same container.
A storage account can contain an unlimited number of containers, and each container can contain an unlimited number of blobs up to the maximum limit of the storage account size (up to 500 TB).
To reference this blob, once it is placed in a container inside a storage account, we can use the URL, which looks like http://mystorageaccount.blob.core.windows.net/mycontainer/myblob.
Blob storage is based on a flat storage schema. So you can’t create a container within a container. For example: once we create a container like videos and if we want to differentiate between professional videos and personal videos. We can then prefix the blob names with personal for personal videos and professional for professional videos. The blob name will appear as personal-video1, personal-video2 for personal videos, and for professional videos – professional-video1, professional-video2. Like this, we can create a virtual hierarchy, but we can’t create a container within a container inside the Azure Blob storage service.
Blob Types
Azure offers three types of blob services:
- Block blob: It stores textual binary data up to about 4.7 TB. It is a block of data that we can manage individually. We can use data blocks mainly to improve download time when we bulk upload data to Azure. When we upload video files, media files, or documents. We can generally use block blobs, unless they are log files.
- Append blob: It contains blocks like block blobs optimized for append operations. It is ideal for an application like logging virtual machine data. For example, application log, event log where you need to append the data to the end of the file. So, when we upload a blob to a container using the Azure portal or code, we can specify the blob type at that time.
- Page Blob: It stores random access files up to 8TB. Page Blobs store VHD files that back up VMs.
Most of the time, we work with block and append blobs. Page blobs are created by default. When we create a virtual machine, the storage account is created and contains the virtual machine’s disks. But for most storage solutions, as we know, we are developing an application like YouTube, or we are developing a surveillance application, in this case, we use either block blobs or append blobs depending on the needs.
Naming and referencing
The container and blob names must follow certain rules. The container and blob names will be part of the URL when you try to access them. They must follow certain rules defined below.
Container names
- Container names must begin with a letter or number, and can only contain letters, numbers, and the hyphen (-) character.
- All letters in a container name must be lowercase.
- Container names must be 3 to 63 characters long.
Name of the Blobs
- Blob names can contain any combination of characters.
- Blob names must be at least one character long and cannot exceed 1024 characters.
- The Azure Storage Emulator supports blob names up to 256 characters.
- Blob names are case sensitive.
- Reserved URL characters must be escaped properly.
Metadata and Snapshots
We can store some information about a container or blob as metadata. This is a name-value pair associated with the container or blob. Metadata names must follow the C# identifier naming rules. For example, when we are developing a video streaming application whose backend is Azure blob storage, when the user uploads a video, we want to store the user’s information as metadata for that video. This is very useful when we start developing an application based on blob storage.
Blob Snapshots
A snapshot is a read-only version of blob storage. Snapshots can ultimately be used to create a backup or checkpoint of a blob. The name of a snapshot blob includes the URL of the base blob plus a date and time value that indicates when the snapshot was created. Again, if we’re developing a YouTube-like application and want to preserve the previous version of the video, we can take a snapshot and store it after the user updates the video. This way, a user like SharePoint can see the previous version of the video and the current version of the video.
To access the snapshot, we need to add a query string to the end of the URL. And a snapshot with a date and time similar to the snapshot creation date and time.