ARTICLE AD BOX
DeleteBlobIfExistsAsync will not throw errors if it cannot locate the file to delete, that is why you are using the IfExists logic so you can use boolean logic instead of handling exceptions. The common reason it returns false is that the file to delete was not found.
Check that the path to the blob is correct:
var blob = blobContainer.GetBlockBlobReference(path); var exists = await blob.ExistsAsync() System.Diagnostics.Trace.WriteLine($"Deleting blob at path: {path} {(exists ? "" : "NOT FOUND!" )}"); await.DeleteIfExistsAsync();Note that the path is case sensitive and relative to the container. Many applications store the full path to blobs including the container as the root folder in the path, if this is affecting you then you will need to trim the root folder from the path.
17.1k3 gold badges57 silver badges101 bronze badges
DeleteBlobIfExistsAsync() is a method on a container, not on the blob service client. So you'd need to do something like:
var containerClient = serviceClient.GetBlobContainerClient(containerName); await containerClient.DeleteBlobIfExistsAsync(blobName);You can also call DeleteIfExistsAsync() on a blob:
var blobClient = containerClient.GetBlobClient(blobName); await blobClient.DeleteIfExistsAsync();Lastly: if you want exceptions thrown, use the methods without IfExists:
await containerClient.DeleteBlobAsync(blobName); await blobClient.DeleteAsync();71k22 gold badges145 silver badges204 bronze badges
Explore related questions
See similar questions with these tags.
