title: Cannot delete the blob that triggers an Azure Function Blob Input Binding
body: <p>This is a follow-up question to this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/42129429/how-to-delete-a-blob-using-azure-functions">How to delete a blob using Azure Functions?</a></p>
  
  <p>When a blob triggers my Azure Function, I need to delete it once its processing is done. Otherwise, I will end up with many blobs in the container.</p>
  
  <p>When I run the following code:</p>
  
  <pre><code>CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connection);
  var blobClient = storageAccount.CreateCloudBlobClient();
  var container = blobClient.GetContainerReference("process");
  var blockBlob = container.GetBlockBlobReference($"process/in/{name}"); // ==&gt; This was the problem. See the answer for more info. 
  bool deleted = blockBlob.DeleteIfExists();
  </code></pre>
  
  <p>the method <code>blockBlob.DeleteIfExists()</code> always returns false and it never deletes the blob.</p>
  
  <p>My guess is that the blob is somehow locked by the function execution since it just triggered it.</p>
  
  <p>[Update 1]</p>
  
  <p>...</p>
  
  <p>[Update 2]</p>
  
  <p>Many thanks to @Jerry Liu, the issue had nothing to do with Azure Fundctions.</p>
  
  <p>The trick is that <code>blockBlob.DeleteIfExists()</code> returns false when caller sends a wrong path by mistake.</p>
  
  <p>A better approach could be using 'blockBlob.Delete' and find out what is the actual issue. </p>
  
  <p>See DeleteIfExists source code for more info.</p>
  
  <p><a href="https://github.com/Azure/azure-storage-net/blob/master/Lib/ClassLibraryCommon/Blob/CloudBlob.cs#L1993" rel="nofollow noreferrer">https://github.com/Azure/azure-storage-net/blob/master/Lib/ClassLibraryCommon/Blob/CloudBlob.cs#L1993</a></p>
  
  <p>Another related question:
  <a href="https://stackoverflow.com/questions/48105181/azure-cloudblockblob-deleteifexists-does-false-always-mean-the-blob-doesnt">Azure CloudBlockBlob.DeleteIfExists() - Does false always mean the blob doesn&#39;t exist?</a></p>