Book Image

Microsoft Azure Development Cookbook Second Edition

Book Image

Microsoft Azure Development Cookbook Second Edition

Overview of this book

Table of Contents (15 chapters)
Microsoft Azure Development Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using retry policies with blob operations


A storage operation that accesses the Azure Storage service can fail in various ways. For example, there could be an unexpected timeout if the Storage service is moving a partition for performance reasons, so we are dealing with transient errors. It is advisable, therefore, to code defensively in the assumption that failure could occur unexpectedly.

The Azure Storage library supports defensive coding by providing a retry policy for operations to the Storage service. This is done by default, but the retry policy classes support parameterization and customization of the process.

The CloudBlobClient class has a RetryPolicy property to define it at factory level. In addition, a storage operation on a blob object has a retry policy associated with it through the RetryPolicy property of its BlobRequestOptions parameter. These RetryPolicy properties provide access to a RetryPolicy instance that implements the IRetryPolicy interface and the ShouldRetry method...