How to delete the azure blob (File) using Azure CLI in PowerShell?

To delete the Azure blob using Azure CLI, we can use “az storage blob” command with the “delete” parameter. Before running this command, we first need to make sure that the azure account is connected (az login) and the proper subscription is set (az account set).

To work with the azure storage account we need to authenticate to the storage. We can use storage key or the storage connections string. Here, we have shown how to retrieve the connections string.

$storageaccount = 'az204storage05june'
$connectionstring = az storage account show-connection-string -
n $storageaccount -otsv

The below command will delete the azure storage blob named ‘Test1.txt’ from the storage container container1.

az storage blob delete --account-name $storageaccount `
   --container-name 'container1' `
   --name 'Test1.txt' `
   --connection-string $connectionstring --verbose