I have an image URL and I want to convert it to HttpPostedFileBase in order to delete the image from the Azure Blob.
For example, I have the following image URL
How can I convert it to HttpPostedFileBase in MVC controller?
In order to delete a blob in your storage account, you would need to use Azure Storage SDK (which is essentially a wrapper over Azure Storage REST API). You mentioned that you have the URL of the blob and have access to storage account and key. Using the code like something below, you can delete a blob from your storage account in your MVC controller.
var credentials = new StorageCredentials(accountName, accountKey);
var cloudBlob = new CloudBlob(new Uri(blobUrl), credentials);
cloudBlob.DeleteIfExists();
The code above assumes that you provide blobUrl
as a parameter to your MVC controller.