/**
 * Delete a blob from specified container
 *
 * @param string $containerName Name of the parent container
 *
 * @param string $blobName      Name of the blob to be deleted
 *
 * @return void
 */
function deleteBlob($containerName, $blobName)
{
    try {
        if (WindowsAzureStorageUtil::blobExists($containerName, $blobName)) {
            $_SERVER['REQUEST_URI'] = remove_query_arg(array('delete_blob', 'filename', 'selected_container'), $_SERVER['REQUEST_URI']);
            WindowsAzureStorageUtil::deleteBlob($containerName, $blobName);
        }
    } catch (Exception $e) {
        /* translators: 1: blob (file) name, 2: container name, 3: error message */
        $message = sprintf(__('Error in deleting blob %1$s from container %2$s: %3$s', 'windows-azure-storage'), $blobName, $containerName, $e->getMessage());
        echo '<p class="warning">' . esc_html($message) . '</p>';
    }
}
 /**
  * Genarate a blob name that is unique for the given container.
  *
  * @param string $container The default Azure storage container
  * @param string $blobName  The blob name
  *
  * @return string Unique blob name
  */
 public static function uniqueBlobName($container, $blobName)
 {
     $info = pathinfo($blobName);
     $uploadSubDir = '.' === $info['dirname'] ? '' : $info['dirname'];
     $filename = sanitize_file_name($info['basename']);
     // sanitized blob name
     $blobName = '' === $uploadSubDir ? $filename : $uploadSubDir . '/' . $filename;
     $newInfo = pathinfo($blobName);
     $ext = !empty($newInfo['extension']) ? '.' . $newInfo['extension'] : '';
     $number = '';
     // change '.ext' to lower case
     if ($ext && strtolower($ext) != $ext) {
         $ext2 = strtolower($ext);
         $filename2 = preg_replace('|' . preg_quote($ext) . '$|', $ext2, $filename);
         $blobName2 = '' === $uploadSubDir ? $filename2 : $uploadSubDir . '/' . $filename2;
         // check for both lower and upper case extension or image sub-sizes may be overwritten
         while (WindowsAzureStorageUtil::blobExists($container, $blobName) || WindowsAzureStorageUtil::blobExists($container, $blobName2)) {
             $new_number = $number + 1;
             $filename = str_replace("{$number}{$ext}", "{$new_number}{$ext}", $filename);
             $filename2 = str_replace("{$number}{$ext2}", "{$new_number}{$ext2}", $filename2);
             $number = $new_number;
             $blobName = '' === $uploadSubDir ? $filename : $uploadSubDir . '/' . $filename;
             $blobName2 = '' === $uploadSubDir ? $filename2 : $uploadSubDir . '/' . $filename2;
         }
         return $blobName2;
     }
     while (WindowsAzureStorageUtil::blobExists($container, $blobName)) {
         if ('' === "{$number}{$ext}") {
             $filename = $filename . ++$number . $ext;
         } else {
             $filename = str_replace("{$number}{$ext}", ++$number . $ext, $filename);
         }
         $blobName = '' === $uploadSubDir ? $filename : $uploadSubDir . '/' . $filename;
     }
     return $blobName;
 }
/**
 * Delete a blob from specified container
 * 
 * @param string $containerName Name of the parent container
 *
 * @param string $blobName Name of the blob to be deleted
 * 
 * @return void
 */
function deleteBlob($containerName, $blobName)
{
    try {
        if (WindowsAzureStorageUtil::blobExists($containerName, $blobName)) {
            remove_query_arg('deleteBlob', $_SERVER['REQUEST_URI']);
            WindowsAzureStorageUtil::deleteBlob($containerName, $blobName);
        }
    } catch (Exception $e) {
        echo '<p style="margin: 10px; color: red;">' . 'Error in deleting blob $blobName from container $containerName : ' . $e->getMessage() . "</p><br/>";
    }
}