BlobRequestOptions.AccessCondition Property

Storage Client Library NET API

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

Gets or sets the access condition for the request.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

Usage

Visual Basic
Dim instance As BlobRequestOptions
Dim value As AccessCondition

value = instance.AccessCondition

instance.AccessCondition = value

Syntax

Visual Basic
Public Property AccessCondition As AccessCondition
C#
public AccessCondition AccessCondition { get; set; }
C++
public:
property AccessCondition AccessCondition {
	AccessCondition get ();
	void set (AccessCondition value);
}
J#
JScript

Property Value

Type: Microsoft.WindowsAzure.StorageClient.AccessCondition

A structure that specifies any conditional parameters on the request.

Example

The following example deletes a blob if its ETag matches a specified value.

C# Copy Code
static void DeleteIfMatch(Uri blobEndpoint, string accountName, string accountKey, string eTag)
{
    CloudBlobClient blobClient =
        new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

    //Get a reference to the blob.
    CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");

    //Indicate that any snapshots should be deleted.
    BlobRequestOptions options = new BlobRequestOptions();
    options.DeleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots;

    //Specify the if-match condition. The blob will be deleted if its ETag matches the value passed in.
    options.AccessCondition = AccessCondition.IfMatch(eTag);

    //Delete the blob if the condition is met.
    blob.Delete(options);
}

Remarks

The default access condition for any request is None.

An access condition may specify a condition that must be met for the operation to be performed by the service. The AccessCondition structure provides methods that can be used to specify exactly one of the following access conditions:

  • If-Match, which performs an operation only if the specified Etag value matches the blob's Etag value. Use the IfMatch method to return this access condition.

  • If-None-Match, which performs an operation only if the specified Etag value does not match the blob's Etag value. Use the IfNoneMatch method to return this access condition.

  • If-Modified-Since, which performs an operation only if the resource has been modified since the specified date and time. Use the IfModifiedSince method to return this access condition.

  • If-Not-Modified-Since, which performs an operation only if the resource has not been modified since the specified date and time. Use the IfNotModifiedSince method to return this access condition.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Change History

See Also