One of the more basic aspects of web development is the concept of files. Whether it be for sharing, storing, accessing, or even processing files, there is often a necessity to be able to handle files. Traditionally, you would just store them on your local computer, but when utilizing the cloud, you can’t do that. Instead, many cloud platforms provide a file storage solution.
This guide is going to go over how to set up and integrate a .NET Core application with an Azure storage account. More specifically, we’re going to make an image gallery application. Source code for the finished application is located on github here.
Before we get started, there are some basics to cover. Azure blob storage is Azure’s cloud based solution to file storage. Within Azure itself, it’s called a “storage account”, because it’s not just blobs, but blobs, files, tables, and queues. I’ll typically refer to it as blob storage, because I mainly use blobs and well, blob is a fun word to say. As a side note, a “blob” is an acronym for Binary Large OBject. Azure also provides a solution called “Data Lake Store”. This is their big data solution that I won’t be covering in this guide.
For actual storage and manual viewing of our blobs, Microsoft created a nice desktop utility called “Microsoft Azure Storage Explorer”, available for free download at http://storageexplorer.com/. Not only will this utility allow us to connect to a storage account within Azure, it’ll also allow us to emulate a storage account on our local machine.
From Microsoft themselves on their Azure Storage Introduction:
For users with large amounts of unstructured object data to store in the cloud, Blob storage offers a cost-effective and scalable solution. You can use Blob storage to store content such as:
- Social data such as photos, videos, music, and blogs
- Backups of files, computers, databases, and devices
- Images and text for web applications
- Configuration data for cloud applications
- Big data, such as logs and other large datasets
Every blob is organized into a container. Containers also provide a useful way to assign security policies to groups of objects. A storage account can contain any number of containers, and a container can contain any number of blobs, up to the 500 TB capacity limit of the storage account.
Blob storage offers three types of blobs, block blobs, append blobs, and page blobs (disks).
- Block blobs are optimized for streaming and storing cloud objects, and are a good choice for storing documents, media files, backups etc.
- Append blobs are similar to block blobs, but are optimized for append operations. An append blob can be updated only by adding a new block to the end. Append blobs are a good choice for scenarios such as logging, where new data needs to be written only to the end of the blob.
- Page blobs are optimized for representing IaaS disks and supporting random writes, and may be up to 1 TB in size. An Azure virtual machine network attached IaaS disk is a VHD stored as a page blob.
You can read their introduction here. There is some overlap for sure, but my goal is to provide a user friendly and informative example that is provided open source on github, rather than a comprehensive guide to Azure Storage.