您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

资源提供程序和类型Resource providers and types

部署资源时,经常需要检索有关资源提供程序和类型的信息。When deploying resources, you frequently need to retrieve information about the resource providers and types. 在本文中学习如何:In this article, you learn to:

  • 查看 Azure 中的所有资源提供程序View all resource providers in Azure
  • 检查资源提供程序的注册状态Check registration status of a resource provider
  • 注册资源提供程序Register a resource provider
  • 查看资源提供程序的资源类型View resource types for a resource provider
  • 查看资源类型的有效位置View valid locations for a resource type
  • 查看资源类型的有效 API 版本View valid API versions for a resource type

可以通过门户、PowerShell 或 Azure CLI 执行这些步骤。You can perform these steps through the portal, PowerShell, or Azure CLI.

PowerShellPowerShell

若要查看 Azure 中的所有资源提供程序和订阅的注册状态,请使用:To see all resource providers in Azure, and the registration status for your subscription, use:

Get-AzureRmResourceProvider -ListAvailable | Select-Object ProviderNamespace, RegistrationState

这会返回类似于以下的结果:Which returns results similar to:

ProviderNamespace                RegistrationState
-------------------------------- ------------------
Microsoft.ClassicCompute         Registered
Microsoft.ClassicNetwork         Registered
Microsoft.ClassicStorage         Registered
Microsoft.CognitiveServices      Registered
...

通过注册资源提供程序来配置订阅,以供资源提供程序使用。Registering a resource provider configures your subscription to work with the resource provider. 注册的作用域始终是订阅。The scope for registration is always the subscription. 默认情况下,将自动注册许多资源提供程序。By default, many resource providers are automatically registered. 但可能需要手动注册某些资源提供程序。However, you may need to manually register some resource providers. 若要注册资源提供程序,必须具备为资源提供程序执行 /register/action 操作的权限。To register a resource provider, you must have permission to perform the /register/action operation for the resource provider. 此操作包含在“参与者”和“所有者”角色中。This operation is included in the Contributor and Owner roles.

Register-AzureRmResourceProvider -ProviderNamespace Microsoft.Batch

这会返回类似于以下的结果:Which returns results similar to:

ProviderNamespace : Microsoft.Batch
RegistrationState : Registering
ResourceTypes     : {batchAccounts, operations, locations, locations/quotas}
Locations         : {West Europe, East US, East US 2, West US...}

当订阅中仍有某个资源提供程序的资源类型时,不能注销该资源提供程序。You cannot unregister a resource provider when you still have resource types from that resource provider in your subscription.

若要查看特定资源提供程序的信息,请使用:To see information for a particular resource provider, use:

Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Batch

这会返回类似于以下的结果:Which returns results similar to:

{ProviderNamespace : Microsoft.Batch
RegistrationState : Registered
ResourceTypes     : {batchAccounts}
Locations         : {West Europe, East US, East US 2, West US...}

...

若要查看资源提供程序的资源类型,请使用:To see the resource types for a resource provider, use:

(Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Batch).ResourceTypes.ResourceTypeName

将返回:Which returns:

batchAccounts
operations
locations
locations/quotas

API 版本对应于资源提供程序发布的 REST API 操作版本。The API version corresponds to a version of REST API operations that are released by the resource provider. 资源提供程序启用新功能时,会发布 REST API 的新版本。As a resource provider enables new features, it releases a new version of the REST API.

若要获取资源类型可用的 API 版本,请使用:To get the available API versions for a resource type, use:

((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Batch).ResourceTypes | Where-Object ResourceTypeName -eq batchAccounts).ApiVersions

将返回:Which returns:

2017-05-01
2017-01-01
2015-12-01
2015-09-01
2015-07-01

所有区域都支持 Resource Manager,但部署的资源可能无法在所有区域中受到支持。Resource Manager is supported in all regions, but the resources you deploy might not be supported in all regions. 此外,订阅可能存在一些限制,以防止用户使用某些支持该资源的区域。In addition, there may be limitations on your subscription that prevent you from using some regions that support the resource.

若要获取某一资源类型的受支持位置,请使用。To get the supported locations for a resource type, use.

((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Batch).ResourceTypes | Where-Object ResourceTypeName -eq batchAccounts).Locations

将返回:Which returns:

West Europe
East US
East US 2
West US
...

Azure CLIAzure CLI

若要查看 Azure 中的所有资源提供程序和订阅的注册状态,请使用:To see all resource providers in Azure, and the registration status for your subscription, use:

az provider list --query "[].{Provider:namespace, Status:registrationState}" --out table

这会返回类似于以下的结果:Which returns results similar to:

Provider                         Status
-------------------------------- ----------------
Microsoft.ClassicCompute         Registered
Microsoft.ClassicNetwork         Registered
Microsoft.ClassicStorage         Registered
Microsoft.CognitiveServices      Registered
...

通过注册资源提供程序来配置订阅,以供资源提供程序使用。Registering a resource provider configures your subscription to work with the resource provider. 注册的作用域始终是订阅。The scope for registration is always the subscription. 默认情况下,将自动注册许多资源提供程序。By default, many resource providers are automatically registered. 但可能需要手动注册某些资源提供程序。However, you may need to manually register some resource providers. 若要注册资源提供程序,必须具备为资源提供程序执行 /register/action 操作的权限。To register a resource provider, you must have permission to perform the /register/action operation for the resource provider. 此操作包含在“参与者”和“所有者”角色中。This operation is included in the Contributor and Owner roles.

az provider register --namespace Microsoft.Batch

这将返回“注册正在进行中”的信息。Which returns a message that registration is on-going.

当订阅中仍有某个资源提供程序的资源类型时,不能注销该资源提供程序。You cannot unregister a resource provider when you still have resource types from that resource provider in your subscription.

若要查看特定资源提供程序的信息,请使用:To see information for a particular resource provider, use:

az provider show --namespace Microsoft.Batch

这会返回类似于以下的结果:Which returns results similar to:

{
    "id": "/subscriptions/####-####/providers/Microsoft.Batch",
    "namespace": "Microsoft.Batch",
    "registrationsState": "Registering",
    "resourceTypes:" [
        ...
    ]
}

若要查看资源提供程序的资源类型,请使用:To see the resource types for a resource provider, use:

az provider show --namespace Microsoft.Batch --query "resourceTypes[*].resourceType" --out table

将返回:Which returns:

Result
---------------
batchAccounts
operations
locations
locations/quotas

API 版本对应于资源提供程序发布的 REST API 操作版本。The API version corresponds to a version of REST API operations that are released by the resource provider. 资源提供程序启用新功能时,会发布 REST API 的新版本。As a resource provider enables new features, it releases a new version of the REST API.

若要获取资源类型可用的 API 版本,请使用:To get the available API versions for a resource type, use:

az provider show --namespace Microsoft.Batch --query "resourceTypes[?resourceType=='batchAccounts'].apiVersions | [0]" --out table

将返回:Which returns:

Result
---------------
2017-05-01
2017-01-01
2015-12-01
2015-09-01
2015-07-01

所有区域都支持 Resource Manager,但部署的资源可能无法在所有区域中受到支持。Resource Manager is supported in all regions, but the resources you deploy might not be supported in all regions. 此外,订阅可能存在一些限制,以防止用户使用某些支持该资源的区域。In addition, there may be limitations on your subscription that prevent you from using some regions that support the resource.

若要获取某一资源类型的受支持位置,请使用。To get the supported locations for a resource type, use.

az provider show --namespace Microsoft.Batch --query "resourceTypes[?resourceType=='batchAccounts'].locations | [0]" --out table

将返回:Which returns:

Result
---------------
West Europe
East US
East US 2
West US
...

门户Portal

若要查看 Azure 中的所有资源提供程序和订阅的注册状态,请选择“订阅”。To see all resource providers in Azure, and the registration status for your subscription, select Subscriptions.

选择“订阅”

选择要查看的订阅。Choose the subscription to view.

指定订阅

选择“资源提供程序”并查看可用资源提供程序的列表。Select Resource providers and view the list of available resource providers.

显示资源提供程序

通过注册资源提供程序来配置订阅,以供资源提供程序使用。Registering a resource provider configures your subscription to work with the resource provider. 注册的作用域始终是订阅。The scope for registration is always the subscription. 默认情况下,将自动注册许多资源提供程序。By default, many resource providers are automatically registered. 但可能需要手动注册某些资源提供程序。However, you may need to manually register some resource providers. 若要注册资源提供程序,必须具备为资源提供程序执行 /register/action 操作的权限。To register a resource provider, you must have permission to perform the /register/action operation for the resource provider. 此操作包含在“参与者”和“所有者”角色中。This operation is included in the Contributor and Owner roles. 若要注册资源提供程序,请选择“注册”。To register a resource provider, select Register.

注册资源提供程序

当订阅中仍有某个资源提供程序的资源类型时,不能注销该资源提供程序。You cannot unregister a resource provider when you still have resource types from that resource provider in your subscription.

若要查看特定资源提供程序的信息,请选择“更多服务”。To see information for a particular resource provider, select More services.

选择“更多服务”

搜索“资源浏览器”,然后在可用选项中选择它。Search for Resource Explorer and select it from the available options.

选择“资源浏览器”

选择“提供程序”。Select Providers.

选择“提供程序”

选择想查看的资源提供程序和资源类型。Select the resource provider and resource type that you want to view.

选择“资源类型”

所有区域都支持 Resource Manager,但部署的资源可能无法在所有区域中受到支持。Resource Manager is supported in all regions, but the resources you deploy might not be supported in all regions. 此外,订阅可能存在一些限制,以防止用户使用某些支持该资源的区域。In addition, there may be limitations on your subscription that prevent you from using some regions that support the resource. 资源浏览器显示资源类型的有效位置。The resource explorer displays valid locations for the resource type.

显示位置

API 版本对应于资源提供程序发布的 REST API 操作版本。The API version corresponds to a version of REST API operations that are released by the resource provider. 资源提供程序启用新功能时,会发布 REST API 的新版本。As a resource provider enables new features, it releases a new version of the REST API. 资源浏览器显示资源类型的有效 API 版本。The resource explorer displays valid API versions for the resource type.

显示 API 版本

后续步骤Next steps