C# code to delete a file from blob

Rajnilari2015
Posted by Rajnilari2015 under Azure category on | Points: 40 | Views : 6864
The below code will do so

public void DeleteFromBlob(string filename, string connectionString, string containerName)
       
{
           
// Retrieve storage account from connection string.
           
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

           
// Create the blob client.
           
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

           
// Retrieve reference to a previously created container.
           
CloudBlobContainer container = blobClient.GetContainerReference(containerName);

           
// Retrieve reference to a blob named "myblob.csv".
           
CloudBlockBlob blockBlob = container.GetBlockBlobReference(filename);

           
// Delete the blob.
            blockBlob
.Delete();
       
}

Comments or Responses

Login to post response