[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.]
Returns an access condition such that an operation will be performed only if the resource's ETag value does not match the ETag value provided. Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Returns an access condition such that an operation will be performed only if the resource's ETag value does not match the ETag value provided. Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
| Visual Basic |
|---|
Dim etag As String Dim returnValue As AccessCondition returnValue = AccessCondition.IfNoneMatch(etag) |
Syntax
| Visual Basic |
|---|
Public Shared Function IfNoneMatch ( _ etag As String _ ) As AccessCondition |
| C# |
|---|
public static AccessCondition IfNoneMatch ( string etag ) |
| C++ |
|---|
public: static AccessCondition IfNoneMatch ( String^ etag ) |
| J# |
|---|
| JScript |
|---|
Parameters
- etag
The ETag value to check.
Return Value
A structure specifying the If-None-Match condition.
Example
The following example sets the if-none-match condition to upload a blob only if it does not already exist.
Copy Code | |
|---|---|
static void UploadIfNotExist(Uri blobEndpoint, string accountName, string accountKey)
{
//Create service client for credentialed access to the Blob service.
CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));
//Get a reference to the blob.
CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");
//Specify the if-none-match condition.
BlobRequestOptions options = new BlobRequestOptions();
options.AccessCondition = AccessCondition.IfNoneMatch("*");
try
{
//Upload the blob only if it does not already exist.
blob.UploadText("Upload this blob if it does not already exist.", Encoding.UTF8, options);
}
catch (StorageClientException e)
{
if (e.ErrorCode == StorageErrorCode.BlobAlreadyExists)
{
Console.WriteLine("Blob was not uploaded because it already exists.");
}
else
{
Console.WriteLine(e.Message);
}
}
}
| |
Remarks
Setting this access condition modifies the request to include the HTTP If-None-Match conditional header.
If this access condition is set, the operation is performed only if the ETag of the resource does not match the specified ETag.
To perform the operation only if the resource does not exist, pass the wildcard character (*) for the etag parameter.
See Specifying Conditional Headers for Blob Service Operations for more information.
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.