public void PageBlobReadLockToETagTestAPM()
        {
            byte[]             outBuffer = new byte[1 * 1024 * 1024];
            byte[]             buffer    = GetRandomBuffer(2 * outBuffer.Length);
            CloudBlobContainer container = GetRandomContainerReference();

            try
            {
                container.Create();

                CloudPageBlob blob = container.GetPageBlobReference("blob1");
                blob.StreamMinimumReadSizeInBytes = outBuffer.Length;
                using (MemoryStream wholeBlob = new MemoryStream(buffer))
                {
                    blob.UploadFromStream(wholeBlob);
                }

                using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                {
                    IAsyncResult result = blob.BeginOpenRead(
                        ar => waitHandle.Set(),
                        null);
                    waitHandle.WaitOne();
                    using (Stream blobStream = blob.EndOpenRead(result))
                    {
                        blobStream.Read(outBuffer, 0, outBuffer.Length);
                        blob.SetMetadata();
                        TestHelper.ExpectedException(
                            () => blobStream.Read(outBuffer, 0, outBuffer.Length),
                            "Blob read stream should fail if blob is modified during read",
                            HttpStatusCode.PreconditionFailed);
                    }

                    result = blob.BeginOpenRead(
                        ar => waitHandle.Set(),
                        null);
                    waitHandle.WaitOne();
                    using (Stream blobStream = blob.EndOpenRead(result))
                    {
                        long length = blobStream.Length;
                        blob.SetMetadata();
                        TestHelper.ExpectedException(
                            () => blobStream.Read(outBuffer, 0, outBuffer.Length),
                            "Blob read stream should fail if blob is modified during read",
                            HttpStatusCode.PreconditionFailed);
                    }

                    AccessCondition accessCondition = AccessCondition.GenerateIfNotModifiedSinceCondition(DateTimeOffset.Now.Subtract(TimeSpan.FromHours(1)));
                    blob.SetMetadata();
                    result = blob.BeginOpenRead(
                        accessCondition,
                        null,
                        null,
                        ar => waitHandle.Set(),
                        null);
                    waitHandle.WaitOne();
                    TestHelper.ExpectedException(
                        () => blob.EndOpenRead(result),
                        "Blob read stream should fail if blob is modified during read",
                        HttpStatusCode.PreconditionFailed);
                }
            }
            finally
            {
                container.DeleteIfExists();
            }
        }