### Describe the Bug
Command Name
az consumption budget create
Errors
Command execution fails with error message:
Subscription <subscription id> is not associated with EA offer type (Request ID: <request id>)
which is weird because in the Azure Portal, I am able to create a budget within the same subscription with the same account. (Current offer type is Pay-as-you-go)
az consumption budget create --amount 100 --budget-name testbudget --category cost -e 2020-12-31 -s 2019-01-01 --time-grain annually --resource-group testgroupBudget is being created
azure-cli 2.0.68
command-modules-nspkg 2.0.3
core 2.0.68
nspkg 3.0.4
telemetry 1.0.3
Extensions:
azure-cli-iot-ext 0.7.1
Python (Linux) 3.6.5 (default, Jun 28 2019, 06:19:45)
[GCC 7.4.0]
Ubuntu 18.04 LTS
Can reproduce this with the latest Azure PowerShell modules as well:
Set-AzConsumptionBudget -Name "MyBudget" -Amount 1000 -Debug
Body:
{
"error": {
"code": "400",
"message": "Subscription <GUID> is not associated with EA offer type (Request ID: <GUID>)"
}
}
Same when running this via ARM template
az deployment create
and
az group deployment create
That this is reproducible via ARM template and Powershell cmdlets suggests this is a service issue. I would recommend opening a support ticket via the portal to get more direct access to the service team.
FYI, this seems to be an API-version issue on the various tools. The Azure REST API itself works like a charm as a workaround:
Thanks for your help!
I found out, that via az resource create it also works (despite another error message). I prefer the az way, because it doesn't require that access token stuff...
So I'm going to report another problem I found, because I'm not sure whether it's related to my original post. If not, I can also create a new issue later.
I'm doing
az resource create -g testgroup -n "testbudget2" --resource-type "Microsoft.Consumption/Budgets" --properties "{\"amount\" : 1000, \"category\" : \"Cost\", \"timeGrain\" : \"Monthly\", \"name\" : \"testbudget2\", \"timePeriod\" : {\"startDate\" : \"2019-07-01T00:00:00Z\", \"endDate\" : \"2019-12-31T00:00:00Z\"}}"
and get an error message:
Deployment failed. Correlation ID: <id>. Request is missing a certificate
I can see the created budget in the portal and the activity log doesn't report any error about this operation.
But, if I add contact groups and contact mails, there are no notifications thrown, as far as I saw it from the budget I created yesterday.
Any ideas about that? Any help appreciated!
@axelwogawa regarding Request is missing a certificate -- i have looked into that in #10028 .
The creation is actually successful, but there's only unnecessary GET at the end.
Btw, you could also try az rest command, i think it doesn't have the same problem.
Any updates on this one?
Please update us! This is driving me crazy... Az CLI still broken... Az PSh still broken... sigh
OK, in case it helps others, I am sharing my workaround using New-AzResource (similar to @axelwogawa 's brilliant workaround, which pointed me in the right direction):
$budgetProperties = @{}
$alertsList = @(75,85,95)
$budgetProperties = [ordered]@{
'amount' = $amount
'category' = "Cost"
'name' = $budgetName
'notifications' = @{}
'timeGrain' =$timeGrain
'timePeriod' = @{
'startDate' = $startDate.ToString("yyyy-MM-dd")
'endDate' = $endDate.ToString("yyyy-MM-dd")
}
}
$notificationHash =@{}
Foreach ($threshold in $alertsList) {
$notificationHash = @{
"At$threshold" = [ordered]@{
'enabled' = $true
'operator' = "GreaterThan"
'threshold' = $threshold
'contactEmails' = @("[email protected]","[email protected]")
}
}
$budgetProperties['notifications'] += $notificationHash
}
New-AzResource -ResourceName $budgetName -ResourceGroupName $resourceGroupName -ResourceType "Microsoft.Consumption/budgets" -Properties $budgetProperties -Force -ErrorAction SilentlyContinue
The above uses a Foreach loop to create the nested hash with as many thresholds as you may need (in this example I have 3, declared in a list), and then uses New-AzResource to submit the main hash in -Properties.
BTW: you will get the missing certificate error, as confirmed by @zikalino. That is why I added -ErrorAction SilentlyContinue at the end.
I hope this helps others!
@fayora Any way to use that command to set a budget for an entire subscription not a resource group?
Hi @splatteredbits, Yes! Just remove -ResourceGroupName $resourceGroupName and it will apply at the currently set subscription (i.e., context). So, if this is for a script, you would also want to use something like this before you run New-AzResource:
Set-AzContext -SubscriptionId $SubscriptionId | Out-Null
Any update here related to create budget from arm template? I get the error described in a subject when running ARM, however creating budget and costs alert from portal works for that subscription with no issue, so I guess it's not a problem with subscription.
Ran into this issue today, same error w/ the AzureRM and Az PS cmdlets. I do see the workaround above but it would be nice to have the underlying service bug fixed.
Dang.. that's a shame about this bug. I was just trying to convince many users that the az cli command for managing consumptions would be great.... but....
This talks to an older version of API. This will get updated later this year.
Closing the issue based on above comments. Please reopen if needed, after the update is released, and if you still see the error.
Then the documentation should be updated to reflect this. You can’t just
expect people to “know” randomly. Please update the documentation to
reflect this.
On Sun, Jun 28, 2020 at 8:43 PM ramaganesan-rg notifications@github.com
wrote:
Closing the issue based on above comments. Please reopen if needed, after
the update is released, and if you still see the error.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Azure/azure-cli/issues/9867#issuecomment-650847344,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AG4RCYZAVLO37ITEQFXHJ2DRY7PUZANCNFSM4H6K6LSQ
.>
Kind Regards,
Michael J. Levan
Chief Engineer and Principal DevOps Consultant
CloudDev.Engineering LLC
E – michael.[email protected]
W - https://www.clouddev.engineering/
Good feedback. Agree. we will make the doc changes to reflect that current SDK (all languages) for budget supports EA subscriptions.
Good feedback. Agree. we will make the doc changes to reflect that current SDK (all languages) for budget supports EA subscriptions.
So, can I use these az consumption to create or get budgets if I am on MCA type of agreement? @ramaganesan-rg
Because now I can get them working
az consumption budget list
Command group 'consumption' is in preview. It may be changed/removed in a future release.
This operation is not supported in the version specified in the request.
Please use version 2018-12-01-preview-preview or later. (Request ID: 7942b08e-49f8-4c35-95a2-0ac236937c01)