1
votes

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.

2

2 Answers

1
votes

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();
}
1
votes

You can also use REST Api if you want.

https://docs.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=