question

DKoene-4055 avatar image
0 Votes"
DKoene-4055 asked DKoene-4055 published

Get-AzConsumptionBudget returns 422 (unproccessable entity)

I have a runbook that, since a couple of weeks, returns a 422 while getting a list of budgets in resource groups:

         $budgets = Get-AzConsumptionBudget -ResourceGroupName $rg.ResourceGroupName

This returns a 422 on my test environment. On the acc and prd environment, no such error occurs. This also keeps triggering alerts in my mailbox so I want this fixed.
I ran this locally as well with fiddler, this is the raw request data:

HTTP/1.1 422 Unprocessable Entity
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 216
Content-Type: application/json; charset=utf-8
Expires: -1
session-id: 4d361bc3-d9c6-42a0-a62a-ce8284461cd7
x-ms-request-id: d6cd3373-bbb7-4bbc-8c8e-a99e2f998513
x-ms-correlation-id: d7f8b4d0-f23e-48b6-9109-75a22e6f00cf
x-ms-correlation-request-id: 885e3b11-2393-44a8-80a8-1ccd57318bd3
x-ms-client-request-id: d7d1f605-b216-4d1e-9429-2afe8906e7b1
X-Powered-By: ASP.NET
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-routing-request-id: WESTEUROPE:20220224T084156Z:885e3b11-2393-44a8-80a8-1ccd57318bd3
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Date: Thu, 24 Feb 2022 08:41:56 GMT

{"error":{"code":"422","message":"This operation is not supported in the version specified in the request. Please use version 2018-12-01-preview-preview or later. (Request ID: d6cd3373-bbb7-4bbc-8c8e-a99e2f998513)"}}



As you can see, something is outdated. I tried updating the Az modules in the automation account and Az.Billing specifically, but so far no success. I haven't found anyone with a similar problem.

What is happening?

edit:
The problem started appearing out of the blue february 1st. We weren't working on these systems and no changes were made in our Azure environment's configuration.

azure-automation
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@DKoene-4055 Welcome to Microsoft Q & A Community Forum. When you say its test environment , did you mean your local environment ? Also , can you compare the module versions between test environment and prd environment?

0 Votes 0 ·
DKoene-4055 avatar image DKoene-4055 SwathiDhanwada-MSFT ·

Sorry for the late answer.

The test environment is an azure environment but run in our local tenant. I updated the Az-Billing module on test to the latest version. I can't easily access PRD since the environment is run by our customer. When I have access I'll come back to this.

0 Votes 0 ·
DKoene-4055 avatar image DKoene-4055 SwathiDhanwada-MSFT ·

So I was able to check the Acceptation environment where things also work.

There, Az-Billing is version 1.0.3, and on our test environment the module version is 2.0.1

Edit: I downgraded the test version to 1.0.3 as well, but it gives the same error. I find this really strange because it really does fail on Get-AzConsumptionBudget. Is there something I'm missing?

0 Votes 0 ·

1 Answer

DKoene-4055 avatar image
0 Votes"
DKoene-4055 answered DKoene-4055 published

So, this problem went from a nuisance to preventing me from testing certain functionality. I have looked everywhere yet I seem to be the only one with this problem.

I have tried the following:
Connected to our test environment locally, and then running Get-AzConsumptionBudget. Here we get the information in the original post. I have also noticed that it uses the following endpoint:

GET /subscriptions/<subscription id>/providers/Microsoft.Consumption/budgets?api-version=2018-01-31 HTTP/1.1 -> note the api-version. The error message was "Please use version 2018-12-01-preview-preview or later." I would love to, but I'm stuck with whatever the PS module wants me to use..

If I connect to our client's acceptation environment, It uses the same endpoint but it does return the budgets as expected. It also has api-version=2018-01-31.

Now I checked the Azure Resource explorer to see if there were any differences in Microsoft.Consumption, there I found this in both environments:

"resourceType": "Budgets",
"locations": [],
"apiVersions": [
"2021-10-01",
"2019-10-01",
"2019-05-01",
"2019-04-01-preview",
"2019-03-01-preview",
"2019-01-01-preview",
"2019-01-01",
"2018-12-01-preview",
"2018-10-01",
"2018-08-31",
"2018-06-30",
"2018-03-31",
"2018-01-31",
"2017-12-30-preview"
]

This tells me both of them have 2018-01-31 as a supported version. As a final piece of info, the problems probably started from february 1st, showing up in our logs on february 2nd. I couldnt find any info on whether anything changed on the MS side of things, nothing changed on our side at least. Please help

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.