azure-sdk-for-go: InvalidResourceType when requesting quota usage list

Bug Report

  • Module: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/quota/armquota v0.5.0

  • SDK version : v65.0.0

    • commit : 7393edcd0c85ff6a71dc7b30e28d48629bc69f6b
  • go version go1.18.3 linux/amd64

  • What happened?

A quota NewUsagesClient was created and the NewListPager method is called, which uses the listCreateRequest method. The following error is produced :

2022/07/09 19:45:59 failed to advance page: GET https://management.azure.com/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/providers/Microsoft.Compute/locations/westeurope/providers/Microsoft.Quota/usages
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE: InvalidResourceType
--------------------------------------------------------------------------------
{
  "error": {
    "code": "InvalidResourceType",
    "message": "The resource type 'locations' could not be found in the namespace 'Microsoft.Compute' for api version '2021-03-15-preview'. The supported api-versions are '2015-05-01-preview,2015-06-15,2016-03-30,2016-04-30-preview,2016-08-30,2017-03-30,2017-12-01,2018-04-01,2018-06-01,2018-10-01,2019-03-01,2019-07-01,2019-12-01,2020-06-01,2020-12-01,2021-03-01,2021-04-01,2021-07-01,2021-11-01,2022-03-01'."
  }
}
--------------------------------------------------------------------------------
exit status 1

  • What did you expect or want to happen?

Get a list of current usage for all resources for the scope specified, same as provided here

  • How can we reproduce it?

Create an NewUsagesClient and call the NewListPager method :

func getQuota(location, quotaName, limit string) {

	credentials, err := azidentity.NewClientSecretCredential(tenantId, clientId, clientSecret, nil)

	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()

	client, err := armquota.NewUsagesClient(credentials, nil)

	if err != nil {
		log.Fatal(err)
	}

	pager := client.NewListPager("subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/providers/Microsoft.Compute/locations/westeurope",
	nil)

		for pager.More() {
		nextResult, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range nextResult.Value {
			// TODO: use page item
			_ = v
		}
	}
}
  • Anything we should know about your environment.
    • Azure Public Cloud

Thank you, Erlis

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

The QuotaRP will go to public preview on tentative date 10/20/22. We are working with all the teams to get sign off for public preview sign off. I will will update the exact date, when we get sign off. Thanks Rahul.

@erlisb Apologies for the late reply. Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.