Azure-sdk-for-js: Check whether a storage container or blob already exists

Created on 9 Sep 2019  路  6Comments  路  Source: Azure/azure-sdk-for-js

Is there an easy way to check whether a storage container already exists? Same for a blob.

Client Storage enhancement

Most helpful comment

Maybe the easiest way today is calling getProperties on BlobClient and checking for a 404 status code. I think we should implement exists, however! /cc @XiaoningLiu @jeremymeng

All 6 comments

Maybe the easiest way today is calling getProperties on BlobClient and checking for a 404 status code. I think we should implement exists, however! /cc @XiaoningLiu @jeremymeng

Agree

Maybe the easiest way today is calling getProperties on BlobClient and checking for a 404 status code. I think we should implement exists, however! /cc @XiaoningLiu @jeremymeng

I confirmed with @JeffreyRichter that exists makes some sense, but there's a concern that exists encourages coding patterns that might seem reliable but aren't in practice. For example, upload-if-not-exists might be implemented as if (!(await client.exists())) { await client.upload() } but another node might be running the same check at the same time and the uploads will still clobber each other.

It's still worth implementing exists, though, I think. Python will likely be adding it as well.

hey guys has this ever been implemented?

yeah, has it?

implemented in #5333

Was this page helpful?
0 / 5 - 0 ratings