← 返回命令列表

Linux command

az-resource 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List all resources

az resource list

List resources

az resource list --resource-group [rg_name]

Show a resource

az resource show --ids [/subscriptions/.../resourceGroups/.../providers/.../name]

Show a resource

az resource show --resource-group [rg_name] --resource-type [Microsoft.Web/sites] --name [resource_name]

Delete a resource

az resource delete --ids [resource_id]

Move resources

az resource move --destination-group [dest_rg] --ids [resource_id1] [resource_id2]

Tag a resource

az resource tag --tags [env=prod] [team=backend] --ids [resource_id]

Update a resource

az resource update --ids [resource_id] --set properties.someProperty=value

说明

az resource is a subcommand of the Azure CLI that manages Azure resources generically across all resource types. It provides a unified interface for operations that apply to any resource, regardless of the specific service. Resources in Azure are identifiable entities like virtual machines, storage accounts, or databases. Each has a unique resource ID following the pattern /subscriptions/{sub}/resourceGroups/{rg}/providers/{provider}/{type}/{name}. This command is useful for scripting cross-resource operations, bulk management, and working with resource types that may not have dedicated CLI command groups.

参数

list
List resources with optional filters.
show
Display resource details.
create
Create a resource from properties.
delete
Remove a resource.
update
Modify resource properties.
move
Move resources between groups or subscriptions.
tag
Manage resource tags.
invoke-action
Invoke an action on a resource.
--ids _ids_
One or more resource IDs.
--resource-group _rg_
Resource group name.
--resource-type _type_
Resource type (e.g., Microsoft.Compute/virtualMachines).
--name _name_
Resource name.
--namespace _namespace_
Provider namespace.
--api-version _version_
API version for the resource type.
--set _property=value_
Update a property using JMESPath.
--tags _tags_
Space-separated tags (key=value).
--query-string _query_
Filter resources with OData query.

FAQ

What is the az-resource command used for?

az resource is a subcommand of the Azure CLI that manages Azure resources generically across all resource types. It provides a unified interface for operations that apply to any resource, regardless of the specific service. Resources in Azure are identifiable entities like virtual machines, storage accounts, or databases. Each has a unique resource ID following the pattern /subscriptions/{sub}/resourceGroups/{rg}/providers/{provider}/{type}/{name}. This command is useful for scripting cross-resource operations, bulk management, and working with resource types that may not have dedicated CLI command groups.

How do I run a basic az-resource example?

Run `az resource list` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does list do in az-resource?

List resources with optional filters.