Skip to content

Remove-StorageContainer

Azure: Removes a storage container

param(
	[Parameter(Mandatory = $true)]
	[string]$Name,

	[Parameter(Mandatory = $true)]
	[string]$StorageAccountName
)

try {
	Import-Module Az.Storage -ErrorAction Stop
	$ctx = (Get-AzStorageAccount -ResourceGroupName "*" -Name $StorageAccountName -ErrorAction Stop).Context
	Remove-AzStorageContainer -Name $Name -Context $ctx -Force -ErrorAction Stop
	Write-Output "Successfully removed storage container '$Name'."
} catch {
	Write-Error $_
	exit 1
}

The name of the container to remove.

The name of the storage account.

An interactive directory of PowerShell scripts.