The course is part of these learning pathsSee 2 more
Microsoft Azure Storage Accounts are cloud-based data storage repositories for a variety of data types, including blobs, queues, tables, and files. Managing the data in these accounts is often the responsibility of the application developer who uses this data. This course focuses on blob storage and the tools and methods developers can use to manage blobs in Azure Storage Accounts.
The course begins with a brief review of Azure Storage Accounts and then drills down into the details of blobs storage services, highlighting the different kinds of blobs.
The course then focuses on moving blobs between storage containers within a storage account and moving blobs between different storage accounts, using the AZCopy tool, using PowerShell, and programmatically using C#.NET. Next, the course dives into blob properties and metadata and how to set and retrieve this information using the Azure Portal, PowerShell, and programmatically in C#.NET. The course then moves into blob leasing, what it is used for, and how to obtain and manage blob leases using the Azure CLI, the REST API, and C#.NET. The last topic in this course covers data archiving and retention by levering Storage Tiers, the new Lifecycle Management feature in the Azure Portal, and using the immutable storage policies feature.
- Moving items in blob storage between storage containers
- Moving items in blob storage between storage accounts
- Setting and retrieving blob properties and metadata
- Implementing blob leasing
- Implementing data archiving and retention
- Azure developers who design and build cloud-based applications and services
- People preparing for Microsoft’s Azure AZ-203 exam
You’ll need to have a basic understanding of Azure, have some experience developing scalable solutions, and be skilled in at least one cloud-supported programming language.
Blob containers and objects have a set of properties as shown here. These properties can be accessed using a variety of methods. Visually the Azure portal can be used to display container properties by navigating to the blob container and choosing properties from the settings blade. Object properties can be displayed simply by clicking on the object and inspecting the overview tab.
Programmatically blob properties can be exposed using C# using the Azure storage client for .NET. Retrieving blob properties or metadata is a two-step process. First, the object must be retrieved using the fetch attributes or fetch attributes async method. Then the properties or metadata can be read or set as needed. In this code snippet the first order of business is to retrieve the connection string for the storage account, load the blob client and the images container. Finally, the attributes are listed by calling the list attributes method. The list attributes method uses the fetch attributes method to retrieve the blob container properties and the last two lines output the container name and last modified date in string format.
Metadata on a container or blob can be set using the set metadata or set metadata async methods. Metadata exists as name-value pairs and can be added to a container or blob by calling the add method for the container or the blob. In this example metadata on a container is cleared and then two name-value pairs are added. Remember to use the set metadata or set metadata async method to commit the metadata to the container.
PowerShell can also be used to retrieve blob properties and metadata by using the CloudBlockBlob class from the Microsoft.WindowsAzure.Storage.Blob namespace. In this demonstration I'll use PowerShell to retrieve and set blob properties and metadata.
To work with blob properties and metadata in PowerShell, we first need to set the storage context to the desired storage account and provide the access key. I passed the access key into a variable called sack. Now I'm calling that new Azure storage context command-let, passing in the name of my storage account and passing in the variable containing the storage account key.
The next thing we need to do is to retrieve the desired blob using the get Azure storage blob commandlet, passing in our context, the target container and the specific blob we wish to read the metadata on.
The native object type for retrieve blob is icloud blob which is too generic to work with as is so we'll convert it to a cloud block blob and store the converted object in a new variable called cloud block blob.
Now we're ready to read some of the properties of the blob. Note that some properties are properties of the object while others are technically properties of the properties.
Some property values can be set. In this example the content type is set to image/jpg. The value is committed using the set properties method.
Initially there is no metadata associated with a blob or a container, but it can be set as needed. In this example I have added a key-value pair of object type equals nebula and photographer equals stillman and committed the metadata using the set metadata method.
Finally, reading the metadata is performed by using the metadata property of the CloudBlockBlob object. Now we can see that my name-value pairs have been set.
As a final note, blob properties and metadata can also be accessed programmatically using the Azure Storage REST API. The specifics are beyond the scope of this course, but details on leveraging this method can be found at this URL (https://docs.microsoft.com/azure/storage/common/storage-rest-api-auth).
- Course Introduction
- Creating an Azure Storage Account
- Moving Blobs Between Storage Containers
- Moving Blobs Between Storage Accounts
- Setting and Retrieving Blob Properties and Metadata
- Implementing Blob Leasing
- Implementing Data Archiving and Retention
Jeff is a technical trainer and developer residing in Arizona, USA. He has been a Microsoft Certified Trainer for the past 18 years, providing in-house development and training on Microsoft server operating systems, PowerShell, SQL Server and Azure. When he’s not developing and delivering courses on Azure, he’s photographing galaxies, nebulae and star formations from his computer-automated observatory in Chino Valley, Arizona using a 14” Schmidt Cassegrain telescope.