Begins an asynchronous operation to populate the blob's properties and metadata, using a conditional request based on the BlobRequestOptions that you specify. Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
Visual Basic |
---|
Dim instance As CloudBlob Dim options As BlobRequestOptions Dim callback As AsyncCallback Dim state As Object Dim returnValue As IAsyncResult returnValue = instance.BeginFetchAttributes(options, callback, state) |
Syntax
Visual Basic |
---|
Public Function BeginFetchAttributes ( _ options As BlobRequestOptions, _ callback As AsyncCallback, _ state As Object _ ) As IAsyncResult |
C# |
---|
public IAsyncResult BeginFetchAttributes ( BlobRequestOptions options, AsyncCallback callback, Object state ) |
C++ |
---|
public: IAsyncResult^ BeginFetchAttributes ( BlobRequestOptions^ options, AsyncCallback^ callback, Object^ state ) |
J# |
---|
JScript |
---|
Parameters
- options
Type: Microsoft.WindowsAzure.StorageClient.BlobRequestOptions
An object that specifies any additional options for the request.
- callback
Type: System.AsyncCallback
The callback delegate that will receive notification when the asynchronous operation completes.
- state
Type: System.Object
A user-defined object that will be passed to the callback delegate.
Return Value
Type: System.IAsyncResultAn IAsyncResult that references the asynchronous operation.Example
The following code example creates an instance of a blob in the cloud, and populates it with metadata. It then creates a second blob that references the same blob instance, and populates it’s properties and metatdata using an asynchronous call—specifying request options.
C# | Copy Code |
---|---|
private void Eg_AsyncListBlobPropertiesAndMetadata2(Uri blobEndpoint, string accountName, string accountKey) { // Create a service client for credentialed access to the Blob service. CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey)); // Create a blob reference. CloudBlob myBlob = blobClient.GetBlobReference("mycontainer/myblob.txt"); // Write text to the blob. myBlob.UploadText("One man that has a mind and knows it can always beat ten men who haven't and don't."); // Define metadata for the blob. myBlob.Metadata["category"] = "quotes"; myBlob.Metadata["owner"] = "George Bernard Shaw"; // Update the blob instance with the new metadata. myBlob.SetMetadata(); // Create a second blob reference, that references the same blob instance. CloudBlob myBlob2 = blobClient.GetBlobReference("mycontainer/myblob.txt"); // Set options for the request. E.g., Specify an operation timeout of 20 seconds. BlobRequestOptions options = new BlobRequestOptions(); options.Timeout = TimeSpan.FromSeconds(20.0); // At this point, myBlob2 has neither system properties nor metadata. // Populate the blob's attributes. // Use aResult to determine when this asynchronous call has completed. IAsyncResult aResult = myBlob2.BeginFetchAttributes(options, Eg_BeginFetchAttributesCallback, myBlob2); // The properties and metatdata won't appear on the blob // until the asynchronous call has completed. while (!aResult.IsCompleted) { // The calling thread can perfrom other work while the asynchronous call completes. Thread.Sleep(100); } // Verify that myBlob2's properties and metadata have in fact been populated. Console.WriteLine("Blob:\t" + myBlob2.Attributes.Uri); Console.WriteLine(); Console.WriteLine("Blob properties:"); Console.WriteLine("BlobType:\t\t" + myBlob2.Attributes.Properties.BlobType); Console.WriteLine("LastModifiedUTC:\t" + myBlob2.Attributes.Properties.LastModifiedUtc); Console.WriteLine("ETag:\t" + myBlob2.Attributes.Properties.ETag); Console.WriteLine(); //Enumerate the blob's metadata. foreach (var metadataKey in myBlob2.Metadata.Keys) { Console.WriteLine("Metadata name:\t" + metadataKey.ToString()); Console.WriteLine("Metadata value:\t" + myBlob2.Metadata.Get(metadataKey.ToString())); } private void Eg_BeginFetchAttributesCallback(IAsyncResult result) { CloudBlob blobForAttributes = (CloudBlob)result.AsyncState; blobForAttributes.EndFetchAttributes(result); } |
Remarks
The BeginFetchAttributes method begins an operation to populate the blob's system properties and user-defined metadata. Before reading a blob's properties or metadata, you should always call this method or the FetchAttributes method to retrieve the latest values for the blob's properties and metadata from the service.