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=";