Closed DapiCloud closed 3 years ago
@bgsky @ms-premp Can you take alook?
@DapiCloud is it a consistent repro for you ? Based on what I see, this seems to something transient. Please confirm, if this issue still persists or you were able to get past this.
@DapiCloud I can confirm that you are able to create budgets.. hence closing this issue. Please let us know, if otherwise.
Geez guys, can ya give me a little more that 30 min to respond here? lol
Issue is still happening, just confirmed again. Note, I have NEVER gotten this command to work using the repro code or any other.
I was able to successfully run New-AzResourceGroup
under same PS session and that worked like a charm!
@ms-premp can you take a look? I believe that the customer can make these changes through portal, but not PowerShell
Anyone? @markcowl @ms-premp
@ms-premp I am having this same issue in PowerShell and CloudShelll with both the New-AzConsumptionBudget and Set-AzConsumptionBudgt cmdlets. I have also confirmed the error is due to the parameter "-contactGroup"
This is something reocurring very often, we do use New-AzDeployment to provision budget via ARM and 401 Unathorized is the almost all the time. Permissions we use are really fine... Can someone have a deeper look at it? Might be related to not fixed: https://github.com/Azure/azure-sdk-for-python/issues/4362
@rkapso please take a look.
@ms-premp @rkapso i have done plenty of test till now and found something. In our pipeline we create dates to put as Start & End for budget:
$date = Get-Date
$year = $date.Year
$month = $date.Month
$date = $date.AddYears(1)
$endYear = $date.Year
$startDate = Get-Date -Year $year -Month $month -Day 1
$endDate = Get-Date -Year $endYear -Month $month -Day 1
$startDateStr = '{0:yyyy-MM-dd}' -f $startDate
$endDateStr = '{0:yyyy-MM-dd}' -f $endDate
and then these are passed to the New-AzDeployment as parameters for Start & End... and we noticed that changing these dates to:
$startDateStr= ((Get-Date -Year $year -Month $month -Day 1).ToUniversalTime()).ToString("yyyy-MM-ddT00:00:00Z")
$endDateStr= ((Get-Date -Year $endYear -Month $month -Day 1).ToUniversalTime()).ToString("yyyy-MM-ddT00:00:00Z")
allows us to create the budget.
401 Unathorized is very not intuitive here. Can this be changed to proper error output?
I had the same 401 error, and solved it by passing the id of my action group to -ContacGroup.
$actionGroupId = (Get-AzureRmActionGroup -ResourceGroupName 'myRgName' -Name 'myActionGroupName).id
New-AzConsumptionBudget -ResourceGroupName 'myRgName' -Name 'myBudgetName' -Amount 100 -Category Cost -TimeGrain Monthly -NotificationThreshold 100 -NotificationKey 'myNKey' -ContactEmail My.Email@xxx.ca -ContactGroup $actionGroupId -StartDate 2020-01-01 -EndDate 2020-01-31
Hope it helps.
The thing here is that 401 is the error code in Azure Budgets for almost everything, no matter what is the real issue type. Bad json? Error 401. Incorrect paremeter? Error 401. Typo? Error 401. Terrible error handling.
@tzheng27 That worked. I had the same problem where I tried to add the "-ContactGroup" parameter and it started failing. MS documentation says that it should be a system string which i think might need to be updated to clarify that it needs to be a string of the resource ID. https://docs.microsoft.com/en-us/powershell/module/az.billing/new-azconsumptionbudget?view=azps-3.4.0. Thanks for the information.
@ms-premp any news on this issue?
@rkapso Please verify.
Team is investigating.
I had the same 401 error, and solved it by passing the id of my action group to -ContacGroup.
$actionGroupId = (Get-AzureRmActionGroup -ResourceGroupName 'myRgName' -Name 'myActionGroupName).id
New-AzConsumptionBudget -ResourceGroupName 'myRgName' -Name 'myBudgetName' -Amount 100 -Category Cost -TimeGrain Monthly -NotificationThreshold 100 -NotificationKey 'myNKey' -ContactEmail My.Email@xxx.ca -ContactGroup $actionGroupId -StartDate 2020-01-01 -EndDate 2020-01-31
Hope it helps.
No, I have tried, Still, I am facing the issue "Bad Request"
Latest doc (https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/quick-create-budget-template?tabs=CLI) is explicit about using id instead of name of action group. Have you tried this?
Closing this issue. Please feel free to reopen as needed.
I still cant create budget due to "bad request" error, please help
Description
Unable to create new budget via
Az.Billing.New-AzConsumptionBudget
. Error returns in both local PowerShell and in Automation Runbook.I am able to create budgets in Azure Portal with no problem.
I am able to run
Get-AzConsumptionBudget
under same context and I get the expected results.Steps to reproduce
Environment data
Module versions
Debug output
Error output