Remove-AzResource
Syntax
ByResourceId (Default)
Remove-AzResource
-ResourceId <String>
[-AsJob]
[-ODataQuery <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
BySubscriptionLevel
Remove-AzResource
-ResourceName <String>
-ResourceType <String>
[-AsJob]
[-ExtensionResourceName <String>]
[-ExtensionResourceType <String>]
[-ODataQuery <String>]
[-ResourceGroupName <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByTenantLevel
Remove-AzResource
-ResourceName <String>
-ResourceType <String>
[-AsJob]
[-ExtensionResourceName <String>]
[-ExtensionResourceType <String>]
[-ODataQuery <String>]
[-TenantLevel]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Remove-AzResource cmdlet removes an Azure resource.
Examples
Example 1: Remove a website resource
Remove-AzResource -ResourceId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup11/providers/Microsoft.Web/sites/ContosoSite" -Force
This command removes the website resource named ContosoSite.
The example uses a placeholder value for the subscription ID.
The command specifies the Force parameter.
Therefore, it does not prompt you for confirmation.
Parameters
-ApiVersion
Specifies the version of the resource provider API to use.
If you do not specify a version, this cmdlet uses the latest available version.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-AsJob
Run cmdlet in the background
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ExtensionResourceName
Specifies the name of an extension resource of the resource that this cmdlet removes.
For instance, to specify a database, use the following format:
server name/
database name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
BySubscriptionLevel
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByTenantLevel
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ExtensionResourceType
Specifies the resource type for an extension resource.
Specifies the extension resource type for the resource.
For instance:
Microsoft.Sql/Servers/Databases
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
BySubscriptionLevel
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByTenantLevel
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Force
Forces the command to run without asking for user confirmation.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ODataQuery
Specifies an Open Data Protocol (OData) style filter.
This cmdlet appends this value to the request in addition to any other filters.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Pre
Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
Specifies the name of the resource group from which this cmdlet removes a resource.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
BySubscriptionLevel
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceId
Specifies the fully qualified resource ID of the resource that this cmdlet removes.
The ID includes the subscription, as in the following example:
/subscriptions/
subscription ID/providers/Microsoft.Sql/servers/ContosoServer/databases/ContosoDatabase
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Id
Parameter sets
ByResourceId
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceName
Specifies the name of the resource that this cmdlet removes.
For instance, to specify a database, use the following format:
ContosoServer/ContosoDatabase
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Name
Parameter sets
BySubscriptionLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByTenantLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceType
Specifies the type of the resource that this cmdlet removes.
For instance, for a database, the resource type is as follows:
Microsoft.Sql/Servers/Databases
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
BySubscriptionLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByTenantLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-TenantLevel
Indicates that this cmdlet operates at the tenant level.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByTenantLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs