Begins an asynchronous operation to update the blob's 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.BeginSetMetadata(options, callback, state) |
Syntax
Visual Basic |
---|
Public Function BeginSetMetadata ( _ options As BlobRequestOptions, _ callback As AsyncCallback, _ state As Object _ ) As IAsyncResult |
C# |
---|
public IAsyncResult BeginSetMetadata ( BlobRequestOptions options, AsyncCallback callback, Object state ) |
C++ |
---|
public: IAsyncResult^ BeginSetMetadata ( 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 then populates it’s metatdata using an asynchronous call—specifying request options.
C# | Copy Code |
---|---|
private void Eg_BeginSetMetadata2(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"; // 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, myBlob still has no metadata. // Set the blob's metadata. // Use aResult to determine when this asynchronous call has completed. IAsyncResult aResult = myBlob.BeginSetMetadata(options, Eg_BeginSetMetadataCallback, myBlob); // The 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 myBlob's metadata has been populated by enumerating it's metadata. foreach (var metadataKey in myBlob.Metadata.Keys) { Console.WriteLine("Metadata name:\t" + metadataKey.ToString()); Console.WriteLine("Metadata value:\t" + myBlob.Metadata.Get(metadataKey.ToString())); } } private void Eg_BeginSetMetadataCallback(IAsyncResult result) { CloudBlob blob = (CloudBlob)result.AsyncState; blob.EndSetMetadata(result); } |
Remarks
The BeginSetMetadata method writes the metadata values that are specified by the blob's Metadata property to the service. Note that setting the Metadata property sets metadata values on the blob reference only; you must call BeginSetMetadata or SetMetadata to write them to the service.