Resources - az resource

Manage Azure resources.

Commands

az resource create Create a resource.
az resource delete Delete a resource. Reference the examples for help with arguments.
az resource link Manage links between resources.
az resource link create Create a new link between resources.
az resource link delete Delete a link between resources.
az resource link list List all resource links.
az resource link show Show a specific link.
az resource link update Update link between resources.
az resource list List resources.
az resource move Moves resources from one resource group to another(can be under different subscription).
az resource show Get information about a resource.
az resource tag Tag a resource. Reference the examples for help with arguments.
az resource update Update a resource.

az resource create

Create a resource.

az resource create --properties
[--api-version]
[--id]
[--is-full-object]
[--location]
[--name]
[--namespace]
[--parent]
[--resource-group]
[--resource-type]

Examples

Create a resource, such as an API App, by providing a full resource object json. Note, you can also use `@<file>` to load from a json file.

az resource create -g myRG -n myApiApp --resource-type Microsoft.web/sites --is-full-object --properties "{"kind":"api", "location":"West US", "properties":{"serverFarmId":"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/myRG/providers/Microsoft.Web/serverfarms/appServicePlan1"}}"

Create a resource, such as a Web App, by only providing resource properties

az resource create -g myRG -n myWeb --resource-type Microsoft.web/sites --properties "{"serverFarmId":"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/myRG/providers/Microsoft.Web/serverfarms/appServicePlan1"}"

Required Parameters

--properties -p

A JSON-formatted string containing resource properties.

Optional Parameters

--api-version

The api version of the resource (omit for latest).

--id

Resource ID.

--is-full-object

Indicates that the properties object includes other options such as location, tags, sku, and/or plan.

--location -l

Location. You can configure the default location using az configure --defaults location=.

--name -n

The resource name. (Ex: myC).

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az resource delete

For example, /subscriptions/0000/resourceGroups/MyResourceGroup/providers/Microsoft.Provider/ResA/MyA/ResB/MyB/ResC/MyC.

az resource delete [--api-version]
[--name]
[--namespace]
[--parent]
[--resource-group]
[--resource-type]

Examples

Delete a virtual machine.

az vm delete -g MyResourceGroup -n MyVm --resource-type "Microsoft.Compute/virtualMachines"

Delete a web app using a resource identifier.

az resource delete --id /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyWebapp

Delete a subnet using a resource identifier.

az resource delete --id /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/MySubnet

Optional Parameters

--api-version

The api version of the resource (omit for latest).

--name -n

The resource name. (Ex: myC).

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az resource list

List resources.

az resource list [--location]
[--name]
[--namespace]
[--resource-group]
[--resource-type]
[--tag]

Examples

List all resource in a region.

az resource list --location westus

List resource using a name.

az resource list --name thename

List resources using a tag.

az resource list --tag something

List resources using a tag with a particular prefix.

az resource list --tag some*

List resources using a tag value.

az resource list --tag something=else

Optional Parameters

--location -l

Location. You can configure the default location using az configure --defaults location=.

--name -n

The resource name. (Ex: myC).

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

--tag

A single tag in 'key[=value]' format. Use "" to clear existing tags.

az resource move

Moves resources from one resource group to another(can be under different subscription).

az resource move --destination-group
--ids
[--destination-subscription-id]

Required Parameters

--destination-group

The destination resource group name.

--ids

The space separated resource ids to be moved.

Optional Parameters

--destination-subscription-id

The destination subscription identifier.

az resource show

For example /subscriptions/0000/resourceGroups/MyResourceGroup/providers/Microsoft.Provider/ResA/MyA/ResB/MyB/resC/MyC.

az resource show [--api-version]
[--name]
[--namespace]
[--parent]
[--resource-group]
[--resource-type]

Examples

Show a virtual machine.

az vm show -g MyResourceGroup -n MyVm --resource-type "Microsoft.Compute/virtualMachines"

Show a web app using a resource identifier.

az resource show --id /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyWebapp

Show a subnet.

az resource show -g MyResourceGroup -n MySubnet --namespace microsoft.network --parent virtualnetworks/MyVnet --resource-type subnets

Show a subnet using a resource identifier.

az resource show --id /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/MySubnet

Show an application gateway path rule.

az resource show -g MyResourceGroup --namespace Microsoft.Network --parent applicationGateways/ag1/urlPathMaps/map1 --resource-type pathRules -n rule1

Optional Parameters

--api-version

The api version of the resource (omit for latest).

--name -n

The resource name. (Ex: myC).

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az resource tag

For example, /subscriptions/0000/resourceGroups/MyResourceGroup/providers/Microsoft.Provider/ResA/MyA/ResB/MyB/resC/MyC.

az resource tag --tags
[--api-version]
[--name]
[--namespace]
[--parent]
[--resource-group]
[--resource-type]

Examples

Tag a virtual machine.

az resource tag --tags vmlist=vm1 -g MyResourceGroup -n MyVm --resource-type "Microsoft.Compute/virtualMachines"

Tag a web app using a resource identifier.

az resource tag --tags vmlist=vm1 --id /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyWebapp

Required Parameters

--tags

Space separated tags in 'key[=value]' format. Use "" to clear existing tags.

Optional Parameters

--api-version

The api version of the resource (omit for latest).

--name -n

The resource name. (Ex: myC).

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az resource update

Update a resource.

az resource update [--add]
[--api-version]
[--name]
[--namespace]
[--parent]
[--remove]
[--resource-group]
[--resource-type]
[--set]

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .

--api-version

The api version of the resource (omit for latest).

--name -n

The resource name. (Ex: myC).

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.