根据限制检查资源使用情况Check resource usage against limits

本文介绍如何查看已在订阅中部署的每种网络资源类型的数量,以及订阅限制是什么。In this article, you learn how to see the number of each network resource type that you've deployed in your subscription and what your subscription limits are. 根据限制查看资源使用情况的功能有助于跟踪当前使用情况,并为将来使用做出计划。The ability to view resource usage against limits is helpful to track current usage, and plan for future use. 可以使用 Azure 门户PowerShellAzure CLI 跟踪使用情况。You can use the Azure Portal, PowerShell, or the Azure CLI to track usage.

Azure 门户Azure Portal

  1. 登录到 Azure 门户Log into the Azure portal.
  2. 在 Azure 门户左上角选择“所有服务” 。At the top, left corner of the Azure portal, select All services.
  3. 在“筛选器”框中,键入“订阅”。 Enter Subscriptions in the Filter box. 当“订阅”出现在搜索结果中时,请选择它。 When Subscriptions appears in the search results, select it.
  4. 选择要查看其使用情况信息的订阅的名称。Select the name of the subscription you want to view usage information for.
  5. 在“设置” 下选择“使用情况 + 配额” 。Under SETTINGS, select Usage + quota.
  6. 可以选择以下选项:You can select the following options:
    • 资源类型:可以选择所有资源类型,也可以选择要查看的特定资源类型。Resource types: You can select all resource types, or select the specific types of resources you want to view.

    • 提供程序:可以选择所有资源提供程序,也可以选择“计算” 、“网络” 或“存储” 。Providers: You can select all resource providers, or select Compute, Network, or Storage.

    • 位置:可以选择所有 Azure 位置,也可以选择特定位置。Locations: You can select all Azure locations, or select specific locations.

    • 可以选择显示所有资源,也可只显示至少部署了一个资源的资源。You can select to show all resources, or only the resources where at least one is deployed.

      下图中的示例显示了在美国东部至少部署了一个资源的所有网络资源:The example in the following picture shows all of the network resources with at least one resource deployed in the East US:

      查看使用情况数据

      可以通过选择列标题来对列进行排序。You can sort the columns by selecting the column heading. 显示的限制是订阅的限制。The limits shown are the limits for your subscription. 如果需要增加默认限制,请选择“请求增加” ,然后完成并提交支持请求。If you need to increase a default limit, select Request Increase, then complete and submit the support request. 所有资源都具有 Azure 限制中列出的最大限制。All resources have a maximum limit listed in Azure limits. 如果当前限制已达到最大数量,则不能增加限制。If your current limit is already at the maximum number, the limit can't be increased.

PowerShellPowerShell

Note

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

可以在 Azure PowerShell 中运行后面的命令。You can run the commands that follow in Azure PowerShell. 如果在计算机上运行 PowerShell,需要 Azure PowerShell 模块 1.0.0 或更高版本。If you run PowerShell from your computer,you need the Azure PowerShell module, version 1.0.0 or later. 在计算机上运行 Get-Module -ListAvailable Az,找到已安装的版本。Run Get-Module -ListAvailable Az on your computer, to find the installed version. 如果需要进行升级,请参阅 Install Azure PowerShell module(安装 Azure PowerShell 模块)。If you need to upgrade, see Install Azure PowerShell module. 如果在本地运行 PowerShell,则还需运行 Login-AzAccount -EnvironmentName AzureChinaCloud 以登录到 Azure。If you're running PowerShell locally, you also need to run Login-AzAccount -EnvironmentName AzureChinaCloud to log in to Azure.

使用 Get-AzNetworkUsage 根据限制查看使用情况。View your usage against limits with Get-AzNetworkUsage. 以下示例获取在“中国东部”位置至少部署了一个资源的资源的使用情况:The following example gets the usage for resources where at least one resource is deployed in the China East location:

Get-AzNetworkUsage `
  -Location chinaeast `
  | Where-Object {$_.CurrentValue -gt 0} `
  | Format-Table ResourceType, CurrentValue, Limit

你会收到格式与以下示例输出相同的输出:You receive output formatted the same as the following example output:

ResourceType            CurrentValue Limit
------------            ------------ -----
Virtual Networks                   1    50
Network Security Groups            2   100
Public IP Addresses                1    60
Network Interfaces                 1 24000
Network Watchers                   1     1

Azure CLIAzure CLI

如果使用 Azure 命令行接口 (CLI) 命令来完成本文中的任务,请从计算机运行 CLI。If using Azure Command-line interface (CLI) commands to complete tasks in this article, run the CLI from your computer. 本文需要 Azure CLI 2.0.32 或更高版本。This article requires the Azure CLI version 2.0.32 or later. 运行 az --version 查找已安装的版本。Run az --version to find the installed version. 如需进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install the Azure CLI. 在本地运行 Azure CLI 之前,还需要运行 az cloud set -n AzureChinaCloud 以将环境更改为 Azure 中国,然后运行 az login 以登录 Azure。Before you run the Azure CLI locally, you also need to run az cloud set -n AzureChinaCloud to change the environment to Azure China, and then run az login to log in to Azure.

使用 az network list-usages 根据限制查看使用情况。View your usage against limits with az network list-usages. 以下示例获取“美国东部”位置的资源使用情况:The following example gets the usage for resources in the East US location:

az network list-usages \
  --location chinaeast \
  --out table

你会收到格式与以下示例输出相同的输出:You receive output formatted the same as the following example output:

Name                    CurrentValue Limit
------------            ------------ -----
Virtual Networks                   1    50
Network Security Groups            2   100
Public IP Addresses                1    60
Network Interfaces                 1 24000
Network Watchers                   1     1
Load Balancers                     0   100
Application Gateways               0    50