Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.8k stars 320 forks source link

Azurite doesn't support Set Blob Tier operation on lease blob and snapshot blob. #632

Open zzhxiaofeng opened 3 years ago

zzhxiaofeng commented 3 years ago

Error Description: In Azure, it will return error "BlobNotFound" when use Set Blob Tier operation with invalid leaseId or snapshot. But in Azurite, it will set blob tier successfully in this case. Azure error is shown as following: Screenshot 2020-11-23 112344

To Reproduce

import {
  BlobServiceClient
} from "@azure/storage-blob";
import * as assert from "assert"

async function main() {
  const blobServiceClient = await BlobServiceClient.fromConnectionString("Azurite-https-connectionString");
  const containerClient = await blobServiceClient.getContainerClient("<container-name>");
  const blockBlobClient = await containerClient.getBlockBlobClient("<blob-name>");
  const fakeVersion = "2020-04-23T03:21:50.5338150Z";
  const snapshotBlobClient = blockBlobClient.withSnapshot(fakeVersion);
  try{
    await snapshotBlobClient.setAccessTier("Cool");
  }catch(err){
    console.log(err);
    assert.ok((err as any).response.parsedBody.Code === "BlobNotFound");
  }
}

main();

Error Track: The reason maybe is that the parameter leaseId and snapshot are not be processed in Blob Set Tier handler method in azurite. The code is shown as following: https://github.com/Azure/Azurite/blob/master/src/blob/handlers/BlobHandler.ts#L872 Screenshot 2020-11-18 160216

Expected Behavior When use Set Blob Tier operation with invalid leaseId or snapshot, it doesn't set blob tier successfully and return the error "BlobNotFound".

@jongio for notification.

blueww commented 3 years ago

@zzhxiaofeng Thanks for raising the issue! We will evaluate it.

We welcome contribution to Azurite. It would be great if you could contribute the the fix of this issue.

dennisdietrich commented 3 years ago

@blueww, is it possible to increase the priority of this issue? I just ran into this too when trying to set the access tier with a valid lease and getting back a 412 saying There is currently a lease on the blob and no lease ID was specified in the request (to be clear, the lease ID is specified and valid and the same code works perfectly fine against the Blob Storage live site). Thanks!

blueww commented 3 years ago

@dennisdietrich Thanks for the information! We will priority the fix.

We welcome contribution to Azurite. It would be great if you could contribute the the fix of this issue.

blueww commented 3 years ago

Lease ID is already fixed. Keep the issue open for snapshot fix.

blueww commented 3 years ago

Lease ID fix is already released in v3.11.0.

v-xuto commented 3 years ago

azsdk-azurite