Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.16k stars 3.78k forks source link

Get-AZQuotaUsage with -scope of Microsoft.Compute could not get correct result #21546

Open AkishinoShiame opened 1 year ago

AkishinoShiame commented 1 year ago

Description

Following with https://learn.microsoft.com/en-us/powershell/module/az.quota/get-azquotausage?view=azps-9.5.0 Tried with Get-AZQuotaUsage -Scope "Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast" command could not get correct value, only 0. Tired with replace japaneast to other region also shows 0, does not return correct result.

Also find from the document example shared seems this command only output 0?

Please help to check further, thanks.

Issue script & Debug output

PS C:\Users\Admin4Case> Get-AZQuotaUsage -Scope "Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast" -debug
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: [CmdletProcessRecordAsyncStart]: Created new QosEvent for command 'Get-AzQuotaUsage_List'
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages?api-version=2021-03-15-preview
DEBUG: RequestCreated: /Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages?api-version=2021-03-15-preview
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages?api-version=2021-03-15-preview

Headers:
x-ms-unique-id                : 9
x-ms-client-request-id        : b910ffa5-ac58-41e7-8c86-c79f3eeb7abe
CommandName                   : Get-AZQuotaUsage
FullCommandName               : Get-AzQuotaUsage_List
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v9.6.0,PSVersion/v7.3.4,Az.Quota/0.1.0

Body:

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-store, must-revalidate, no-cache
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
MS-RequestId                  : XKrwfyx7_UenvGmv_Dta6A.0
Server                        : Kestrel
x-ms-ratelimit-remaining-subscription-reads: 11991
x-ms-request-id               : dcb3e117-8662-476f-8f89-a4bf09a3f51c
x-ms-correlation-request-id   : dcb3e117-8662-476f-8f89-a4bf09a3f51c
x-ms-routing-request-id       : JAPANEAST:20230414T091252Z:dcb3e117-8662-476f-8f89-a4bf09a3f51c
Date                          : Fri, 14 Apr 2023 09:12:52 GMT

Body:
{
  "value": [
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "availabilitySets",
          "localizedValue": "Availability Sets"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/availabilitySets",
      "type": "Microsoft.Quota/Usages",
      "name": "availabilitySets"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 58
        },
        "name": {
          "value": "cores",
          "localizedValue": "Total Regional vCPUs"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": true
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/cores",
      "type": "Microsoft.Quota/Usages",
      "name": "cores"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 22
        },
        "name": {
          "value": "virtualMachines",
          "localizedValue": "Virtual Machines"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/virtualMachines",
      "type": "Microsoft.Quota/Usages",
      "name": "virtualMachines"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 1
        },
        "name": {
          "value": "virtualMachineScaleSets",
          "localizedValue": "Virtual Machine Scale Sets"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/virtualMachineScaleSets",
      "type": "Microsoft.Quota/Usages",
      "name": "virtualMachineScaleSets"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "dedicatedVCpus",
          "localizedValue": "Dedicated vCPUs"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/dedicatedVCpus",
      "type": "Microsoft.Quota/Usages",
      "name": "dedicatedVCpus"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "cloudServices",
          "localizedValue": "Cloud Services"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/cloudServices",
      "type": "Microsoft.Quota/Usages",
      "name": "cloudServices"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "lowPriorityCores",
          "localizedValue": "Total Regional Low-priority vCPUs"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": true
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/lowPriorityCores",
      "type": "Microsoft.Quota/Usages",
      "name": "lowPriorityCores"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 20
        },
        "name": {
          "value": "StandardDiskCount",
          "localizedValue": "Standard Storage Managed Disks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/StandardDiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "StandardDiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 5
        },
        "name": {
          "value": "PremiumDiskCount",
          "localizedValue": "Premium Storage Managed Disks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/PremiumDiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "PremiumDiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "StandardSSDDiskCount",
          "localizedValue": "StandardSSDStorageDisks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/StandardSSDDiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "StandardSSDDiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "StandardSSDZRSDiskCount",
          "localizedValue": "StandardSSDZRSStorageDisks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/StandardSSDZRSDiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "StandardSSDZRSDiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "PremiumZRSDiskCount",
          "localizedValue": "PremiumZRSStorageDisks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/PremiumZRSDiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "PremiumZRSDiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "UltraSSDDiskCount",
          "localizedValue": "UltraSSDStorageDisks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/UltraSSDDiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "UltraSSDDiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "PremiumV2DiskCount",
          "localizedValue": "PremiumV2StorageDisks"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/PremiumV2DiskCount",
      "type": "Microsoft.Quota/Usages",
      "name": "PremiumV2DiskCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "StandardSnapshotCount",
          "localizedValue": "StandardStorageSnapshots"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/StandardSnapshotCount",
      "type": "Microsoft.Quota/Usages",
      "name": "StandardSnapshotCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "StandardSSDSnapshotCount",
          "localizedValue": "StandardSSDStorageSnapshots"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/StandardSSDSnapshotCount",
      "type": "Microsoft.Quota/Usages",
      "name": "StandardSSDSnapshotCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "PremiumSnapshotCount",
          "localizedValue": "PremiumStorageSnapshots"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/PremiumSnapshotCount",
      "type": "Microsoft.Quota/Usages",
      "name": "PremiumSnapshotCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "ZRSSnapshotCount",
          "localizedValue": "ZrsStorageSnapshots"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/ZRSSnapshotCount",
      "type": "Microsoft.Quota/Usages",
      "name": "ZRSSnapshotCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "UltraSSDDiskSizeInGB",
          "localizedValue": "UltraSSDTotalSizeInGB"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/UltraSSDDiskSizeInGB",
      "type": "Microsoft.Quota/Usages",
      "name": "UltraSSDDiskSizeInGB"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "PremiumV2DiskSizeInGB",
          "localizedValue": "PremiumV2TotalDiskSizeInGB"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/PremiumV2DiskSizeInGB",
      "type": "Microsoft.Quota/Usages",
      "name": "PremiumV2DiskSizeInGB"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "DiskEncryptionSetCount",
          "localizedValue": "DiskEncryptionSets"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/DiskEncryptionSetCount",
      "type": "Microsoft.Quota/Usages",
      "name": "DiskEncryptionSetCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "DiskAccessCount",
          "localizedValue": "DiskAccesses"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/DiskAccessCount",
      "type": "Microsoft.Quota/Usages",
      "name": "DiskAccessCount"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "Gallery",
          "localizedValue": "Gallery"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/Gallery",
      "type": "Microsoft.Quota/Usages",
      "name": "Gallery"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "GalleryImage",
          "localizedValue": "Gallery Image"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/GalleryImage",
      "type": "Microsoft.Quota/Usages",
      "name": "GalleryImage"
    },
    {
      "properties": {
        "usages": {
          "UsagesType": "Independent",
          "Value": 0
        },
        "name": {
          "value": "GalleryImageVersion",
          "localizedValue": "Gallery Image Version"
        },
        "properties": {},
        "unit": "Count",
        "isQuotaApplicable": false
      },
      "id": "/Subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/japaneast/providers/Microsoft.Quota/usages/GalleryImageVersion",
      "type": "Microsoft.Quota/Usages",
      "name": "GalleryImageVersion"
    }
  ]
}

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:

DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent:  Module: Az.Quota:0.1.0; CommandName: Get-AzQuotaUsage_List; PSVersion: 7.3.4; IsSuccess: True; Duration: 00:00:00
DEBUG: Finish sending metric.
DEBUG: CmdletEndProcessing:
Name                             NameLocalizedValue                       UsageUsagesType UsageValue ETag
----                             ------------------                       --------------- ---------- ----
availabilitySets                 Availability Sets                                        0
cores                            Total Regional vCPUs                                     0
virtualMachines                  Virtual Machines                                         0
virtualMachineScaleSets          Virtual Machine Scale Sets                               0
dedicatedVCpus                   Dedicated vCPUs                                          0
cloudServices                    Cloud Services                                           0
lowPriorityCores                 Total Regional Low-priority vCPUs                        0
StandardDiskCount                Standard Storage Managed Disks                           0
PremiumDiskCount                 Premium Storage Managed Disks                            0
StandardSSDDiskCount             StandardSSDStorageDisks                                  0
StandardSSDZRSDiskCount          StandardSSDZRSStorageDisks                               0
PremiumZRSDiskCount              PremiumZRSStorageDisks                                   0
UltraSSDDiskCount                UltraSSDStorageDisks                                     0
PremiumV2DiskCount               PremiumV2StorageDisks                                    0
StandardSnapshotCount            StandardStorageSnapshots                                 0
StandardSSDSnapshotCount         StandardSSDStorageSnapshots                              0
PremiumSnapshotCount             PremiumStorageSnapshots                                  0
ZRSSnapshotCount                 ZrsStorageSnapshots                                      0
UltraSSDDiskSizeInGB             UltraSSDTotalSizeInGB                                    0
PremiumV2DiskSizeInGB            PremiumV2TotalDiskSizeInGB                               0
DiskEncryptionSetCount           DiskEncryptionSets                                       0
DiskAccessCount                  DiskAccesses                                             0
Gallery                          Gallery                                                  0
GalleryImage                     Gallery Image                                            0
GalleryImageVersion              Gallery Image Version                                    0

Environment data

PS C:\Users\Admin4Case> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS C:\Users\Admin4Case> Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.12.1                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     0.1.0                 Az.Quota                            {Get-AzQuota, Get-AzQuotaOperation, Get-AzQuotaRequestStatus, Get-AzQuotaUsage…}

Error output

PS C:\Users\Admin4Case> Resolve-AzError
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
wyunchi-ms commented 1 year ago

Hi @AkishinoShiame , do you mean the UsageValue? Looks it's 0 from server side. I will ask service team for this.

ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

AkishinoShiame commented 1 year ago

Hi @AkishinoShiame , do you mean the UsageValue? Looks it's 0 from server side. I will ask service team for this.

Hi @wyunchi-ms ,

Yes! It seems UsageValue always resopnse with 0, however per understanding it should be same as we could see from portal > subscription > Usage + Quota result value per understanding.

Also, I believe it should be same/similar output of Get-AzVMUsage -Location "Japan East" Value output, which https://learn.microsoft.com/ja-jp/azure/virtual-machines/quotas?tabs=powershell#check-usage shows.

Please help to check further. Thank you! :)

leomozzer commented 11 months ago

I had the same problem. When using the -debug, I could see the real value, but it wasn't been displayed in the "UsageValue". Using the Get-AzVMUsage or Get-AzNetworkUsage I was able to see it.