Reputation: 37
I have an azure blob container name "x" and I want to check if a file name "a.jpg" exists in that blob or not and return true or false based on that. It seems easy but there isn't a clear answer when I google it.
Upvotes: 1
Views: 9079
Reputation: 366
You can also use REST Api if you want.
https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-metadata
A lot more trouble... but works too.
Request The Get Blob Metadata request may be constructed as follows. HTTPS is recommended. Replace myaccount with the name of your storage account:
TABLE 1 GET or HEAD Method Request URI HTTP Version https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=metadata
https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=metadata&snapshot=
Upvotes: 1
Reputation: 222582
It is clearly mentioned in the document, if you are using c# you can use ExistsAsync
method
public async Task<bool> FileExists(string fileName)
{
return await directory.GetBlockBlobReference(fileName).ExistsAsync();
}
Upvotes: 1