0

I was wondering how to tell if the type of azure storage based on SAS URI of blob? or more specifically how to know if it is PageBlob or BlockBlob.

There is a REST API that returns a type of blob by just doing a HEAD request to SAS URI and if the file exists there is a field in the response header x-ms-blob-type which indicates the type of blob. However, if the file doesn't exist it returns 404. Now when we get a 404 we can upload a dummy file using BlockBlob and if it fails then we know it's a PageBlob. But I am wondering is there a better way? more straightforward way.

Example of SAS URI:

var sasUriStr = "https://storageaccountname.blob.core.windows.net/containername/file?sp=r&st=2021-08-10T00:34:00Z&se=2021-08-15T08:34:00Z&spr=https&sv=2020-08-04&sr=c&sig=ABCDEFGH/YJKLMNOP=";
Node.JS
  • 1,042
  • 6
  • 44
  • 114
  • My guess is that you want to find out what kind of blob types (block, page, append) are supported by a storage account. Is that correct? – Gaurav Mantri Aug 21 '21 at 03:36
  • Yes. That's it. However, I don't want to assume for example if it's Premium LRS then it has to support PageBlob. I want to know what it supports based on a SAS URI – Node.JS Aug 21 '21 at 03:40

1 Answers1

1

There's a way to find that information however it requires you to bring in your logic and it requires a different kind of SAS token.

What you have to do is create an Account SAS (currently you're using Service SAS) and then invoke Get Account Information REST API using that token. Next you will need to extract x-ms-sku-name and x-ms-account-kind response headers. Based on the values of these, you will have to come up with a logic for supported blob types. For example,

  • If the value of x-ms-account-kind is BlobStorage, then it only supports Block Blobs and Append Blobs.
  • If the value of x-ms-account-kind is not BlobStorage or BlockBlobStorage and value of x-ms-sku-name is PremiumLRS, then it only supports Page Blobs.

I wrote a blog post some time ago where I created a matrix of features supported by account kinds and skus. You can read that blog post here: https://www.ais.com/how-to-choose-the-right-kind-of-azure-storage-account/

From this blog post:

enter image description here

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • I have a question, Please correct me if I am wrong. Is downloading of PageBlob and BlockBlob the same and write operation is different? I assumed downloading are the same because if we have a blob URI we can just use a GET to download the blob. – Node.JS Sep 10 '21 at 06:42
  • Lastly, is there a documentation that supports my hypothesis of downloading the blob is the same for both of them regardless of type of blob. Maybe this should be a separate question ... – Node.JS Sep 10 '21 at 06:49
  • Downloading blob is the same however page blobs download can be optimized (sparse download) and that makes the download different. Please ask a separate question. – Gaurav Mantri Sep 10 '21 at 07:03
  • Asked as a separate question. Thank you so much as always https://stackoverflow.com/questions/69128675/downloading-of-blob-in-pageblob-vs-blockblob – Node.JS Sep 10 '21 at 07:27
  • how to translate this table into a code? do you have it as a CSV? – Node.JS Oct 26 '21 at 08:46