Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Remove-AzureResource

Remove-AzureResource

microsoft.azure.commands.resources.dll

Synopsis

Deletes a resource

Syntax

Remove-AzureResource [-ApiVersion] [-Force] [-PassThru] [-Name] [-ResourceGroupName] [-ResourceType] [-ParentResource] [-WhatIf] [-Confirm] [<CommonParameters>]

Detailed Description

The Remove-AzureResource cmdlet deletes a resource from your subscription. It does not delete the resource group of the resource. By default, Remove-AzureResource prompts you for confirmation. To suppress the prompt, use the Force parameter.

Parameters

-ApiVersion <String>

Specifies the API version that is supported by the resource provider. This parameter is required.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Force <SwitchParameter>

Suppresses the confirmation prompt. By default, Remove-AzureResource prompts for confirmation before deleting a resource.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-PassThru <SwitchParameter>

Returns $True when the remove operation succeeds and $False otherwise. By default, this cmdlet does not return any output.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Name <String>

Specifies the name of the resource. This parameter is required.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ResourceGroupName <String>

Specifies the name of resource group of the resource. This parameter is required.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ResourceType <String>

Specifies the resource type. Enter a provider qualified name, such as "Microsoft.Web/sites". This parameter is required. Wildcards are not permitted.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ParentResource <String>

Specifies the names of the logical parent of a resource. This parameter is optional. Enter the fully qualified name of the parent resource, such as "Microsoft.Sql/servers/ContosoSQLSvr".

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

None

Return Type

None or Boolean

Notes

The Remove-AzureResource cmdlet is included in the Azure Resource Manager module beginning in module version 0.8.0.

Examples

-------------------------- Example 1: Remove a resource --------------------------

This command removes the ContosoWeb web site from the ContosoRG01 resource group.

PS C:\>Remove-AzureResource -Name ContosoWeb -ResourceGroupName ContosoRG01 -ResourceType Microsoft.web/sites -ApiVersion 2014-04-01 ConfirmAre you sure you want to remove resource ' ContosoWeb'[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

-------------------------- Example 2: Pipe a resource to RemoveAzureResource --------------------------

This command uses the Get-AzureResource cmdlet to get the ContosoDB01 database. The command pipes the database to the Remove-AzureResource cmdlet to remove it. The command uses the Passthru parameter, which causes the cmdlet to return a Boolean value that represents the success or failure of the operation. In this case, it returns True.

PS C:\>Get-AzureResource -Name contosodb01 -ResourceGroupName ContosoRG01 -ResourceType "Microsoft.Sql/servers/databases" -ParentResource "Microsoft.Sql/servers/contososvr01" -ApiVersion 2.0 | Remove-AzureResource -Passthru ConfirmAre you sure you want to remove resource 'contosodb01'[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
True

Online Version