本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.BeginGetBlobReferenceFromServer方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient.BeginGetBlobReferenceFromServer方法的具体用法?C# CloudBlobClient.BeginGetBlobReferenceFromServer怎么用?C# CloudBlobClient.BeginGetBlobReferenceFromServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient
的用法示例。
在下文中一共展示了CloudBlobClient.BeginGetBlobReferenceFromServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloudBlobContainerGetBlobReferenceFromServerAPM
public void CloudBlobContainerGetBlobReferenceFromServerAPM()
{
CloudBlobContainer container = GetRandomContainerReference();
try
{
container.Create();
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy()
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
};
CloudBlockBlob blockBlob = container.GetBlockBlobReference("bb");
blockBlob.PutBlockList(new string[] { });
CloudPageBlob pageBlob = container.GetPageBlobReference("pb");
pageBlob.Create(0);
using (AutoResetEvent waitHandle = new AutoResetEvent(false))
{
IAsyncResult result = container.BeginGetBlobReferenceFromServer("bb",
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob1 = container.EndGetBlobReferenceFromServer(result);
Assert.IsInstanceOfType(blob1, typeof(CloudBlockBlob));
result = ((CloudBlockBlob)blob1).BeginCreateSnapshot(
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
CloudBlockBlob blob1Snapshot = ((CloudBlockBlob)blob1).EndCreateSnapshot(result);
result = blob1.BeginSetProperties(
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
blob1.EndSetProperties(result);
Uri blob1SnapshotUri = new Uri(blob1Snapshot.Uri.AbsoluteUri + "?snapshot=" + blob1Snapshot.SnapshotTime.Value.UtcDateTime.ToString("o"));
result = container.ServiceClient.BeginGetBlobReferenceFromServer(blob1SnapshotUri,
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob1SnapshotReference = container.ServiceClient.EndGetBlobReferenceFromServer(result);
AssertAreEqual(blob1Snapshot.Properties, blob1SnapshotReference.Properties);
result = container.BeginGetBlobReferenceFromServer("pb",
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob2 = container.EndGetBlobReferenceFromServer(result);
Assert.IsInstanceOfType(blob2, typeof(CloudPageBlob));
result = ((CloudPageBlob)blob2).BeginCreateSnapshot(
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
CloudPageBlob blob2Snapshot = ((CloudPageBlob)blob2).EndCreateSnapshot(result);
result = blob2.BeginSetProperties(
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
blob2.EndSetProperties(result);
Uri blob2SnapshotUri = new Uri(blob2Snapshot.Uri.AbsoluteUri + "?snapshot=" + blob2Snapshot.SnapshotTime.Value.UtcDateTime.ToString("o"));
result = container.ServiceClient.BeginGetBlobReferenceFromServer(blob2SnapshotUri,
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob2SnapshotReference = container.ServiceClient.EndGetBlobReferenceFromServer(result);
AssertAreEqual(blob2Snapshot.Properties, blob2SnapshotReference.Properties);
result = container.ServiceClient.BeginGetBlobReferenceFromServer(blockBlob.Uri,
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob3 = container.ServiceClient.EndGetBlobReferenceFromServer(result);
Assert.IsInstanceOfType(blob3, typeof(CloudBlockBlob));
result = container.ServiceClient.BeginGetBlobReferenceFromServer(pageBlob.Uri,
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob4 = container.ServiceClient.EndGetBlobReferenceFromServer(result);
Assert.IsInstanceOfType(blob4, typeof(CloudPageBlob));
string blockBlobToken = blockBlob.GetSharedAccessSignature(policy);
StorageCredentials blockBlobSAS = new StorageCredentials(blockBlobToken);
Uri blockBlobSASUri = blockBlobSAS.TransformUri(blockBlob.Uri);
string pageBlobToken = pageBlob.GetSharedAccessSignature(policy);
StorageCredentials pageBlobSAS = new StorageCredentials(pageBlobToken);
Uri pageBlobSASUri = pageBlobSAS.TransformUri(pageBlob.Uri);
result = container.ServiceClient.BeginGetBlobReferenceFromServer(blockBlobSASUri,
ar => waitHandle.Set(),
null);
waitHandle.WaitOne();
ICloudBlob blob5 = container.ServiceClient.EndGetBlobReferenceFromServer(result);
Assert.IsInstanceOfType(blob5, typeof(CloudBlockBlob));
//.........这里部分代码省略.........