官术网_书友最值得收藏!

Introduction

The Windows Azure Blob Service is the Windows Azure Storage Service feature that manages the storage of file-based entities referred to as blobs. In this chapter, we will focus on the Blob service. In the next two chapters, we will look at the other storage services: the Table service and the Queue service.

The definitive way to access the storage service is through the Windows Azure Storage Service REST API. The Windows Azure Storage Client library is a high-level managed library, included in the Windows Azure SDK, which abstracts the RESTful interface into a set of classes. The Windows Azure Storage Client Protocol classes contained in the Storage Client library expose functionality not provided in the core library classes. Specifically, the protocol classes provide access to the underlying HttpWebRequest object used to invoke the RESTful operations.

Nearly all the recipes in this chapter use the Storage Client library. Scattered through the recipes are examples of how to use it for basic operations, such as creating a container and uploading blobs. However, we use the RESTful interface in the Copying a blob with the Windows Azure Storage Service REST API recipe. It is worthwhile to have some knowledge of the Storage Service REST API because it is informative to look at the raw REST operations sent over the wire to the storage service when debugging problems with storage operations. We use the Protocol classes in the Leasing a blob using the Protocol classes in the Windows Azure Storage Client Library recipe.

There are two types of blob: block blobs optimized for streaming and page blobs optimized for random access. In the Uploading blocks to a block blob recipe, we see how to increase control over the uploading of a block blob by uploading individual blocks and then committing them to create the block blob. In the Uploading a VHD into a page blob recipe, we see how to improve the upload performance by uploading only non-empty pages. The primary use case for page blobs is the storage of VHDs, which can then be attached as an Azure Drive to a role instance.

Blobs can have both properties and metadata associated with them. The properties comprise standard HTTP header fields that provide additional information to clients downloading the blobs. The metadata comprises a sequence of arbitrary name-value pairs. In the Setting properties and metadata for a blob recipe, we see how to use properties and metadata.

The Blob service supports the creation of a blob snapshot to provide a read-only version of the content of a blob when the snapshot is created. A blob can be rolled-back to an earlier state by copying the snapshot over it. An important use case for a snapshot is when its base blob is a VHD page blob. A writable VHD page blob can be attached as an Azure Drive to only one instance at a time. However, a read-only VHD blob snapshot can be attached simultaneously to an unlimited number of instances. The Creating and using a blob snapshot recipe shows us blob snapshots in action.

The Blob service stores blobs in a simple two-level hierarchy of containers and blobs. In the Using blob directories recipe we use the directory support provided by the Blob service to simulate a more complex hierarchy mimicking directories in a file system. In the Creating and using the root container for blobs recipe we see how to create a root directory that allows blobs to appear to be located at the root of the hierarchy and not inside a container. This allows cross-domain policy files to be stored as blobs.

The Storage Client library provides both synchronous and asynchronous versions of almost all methods that access the storage service. The asynchronous methods adhere to the common language runtime Asynchronous Programming Model (APM). In the Downloading a blob asynchronously recipe, we see how easy it is to use the asynchronous methods to download a blob. In the Optimizing blob uploads and downloads recipe, we see how to use the Task Parallel library provided in .NET Framework 4 to improve the performance of blob uploads and downloads by performing operations in parallel.

A storage operation against the storage service may fail for various reasons. Consequently, the Storage Client library provides built-in support for retries of failed operations. In the Using retry policies with blob operations recipe, we see how to parameterize existing retry behavior and implement custom retry functionality.

The Windows Azure Content Delivery Network (CDN) can be used to cache blobs closer to the user. This significantly improves the download performance of blobs. In the Using the Windows Azure Content-Delivery Network (CDN) recipe, we see how to use the CDN. We also see how to configure custom domains for both the Blob service and the CDN.

主站蜘蛛池模板: 田阳县| 万安县| 鄂伦春自治旗| 萨迦县| 德保县| 聊城市| 祁门县| 博乐市| 永城市| 台南市| 汝城县| 辉南县| 东兰县| 长春市| 衡南县| 广灵县| 远安县| 正蓝旗| 延边| 卢氏县| 宜兴市| 沧源| 清远市| 内江市| 彭水| 淄博市| 腾冲县| 胶南市| 龙川县| 富顺县| 九台市| 栾川县| 张家界市| 盐津县| 安仁县| 分宜县| 新野县| 韶关市| 正宁县| 十堰市| 高青县|