azure-cli: az consumption budget create fails with offer type error message
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)
To Reproduce
- in bash, login to Azure account
az consumption budget create --amount 100 --budget-name testbudget --category cost -e 2020-12-31 -s 2019-01-01 --time-grain annually --resource-group testgroup
Expected Behaviour
Budget is being created
Environment Summary
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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 19 (3 by maintainers)
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
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):
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 usesNew-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!
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:
Budgets - Create Or Update
Can reproduce this with the latest Azure PowerShell modules as well:
Set-AzConsumptionBudget -Name "MyBudget" -Amount 1000 -Debug