Repository navigation
Set SubscriptionBudget
Updates the amount of one or more Azure subscription budgets based on recent actual spend.
Set-SubscriptionBudget [[-SubscriptionName] <String[]>] [[-BudgetName] <String>] [[-BillingMonth] <DateTime>]
[[-Months] <Int32>] [[-BufferPercent] <Double>] [[-MinimumAmount] <Double>] [-CreateIfMissing]
[[-TimeGrain] <String>] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Calculates the average cost for a number of previous billing months (via Get-SubscriptionCost) and updates the amount of the subscription's existing consumption budget to match, optionally adding a percentage buffer. This allows a budget to be kept in step with genuinely changing costs, rather than remaining a fixed figure that is manually maintained.
By default the first budget found for the subscription is updated. Use -BudgetName if a subscription has multiple budgets and you want to target a specific one. If no budget exists and -CreateIfMissing is specified, a new monthly budget is created instead.
Set-SubscriptionBudget
Updates the budget for every subscription in the current Azure context to match its average spend over the previous 3 billing months.
Set-SubscriptionBudget -SubscriptionName 'MySubscriptionA' -Months 6 -BufferPercent 10 -WhatIf
Shows what the budget for 'MySubscriptionA' would be updated to, based on its average spend over the previous 6 billing months plus a 10% buffer, without making any change.
Set-SubscriptionBudget -SubscriptionName 'MySubscriptionA' -Months 1 -PassThru
Updates the budget for 'MySubscriptionA' to match its spend for the previous billing month alone, and returns an object describing the change.
Set-SubscriptionBudget -SubscriptionName 'MySubscriptionA' -CreateIfMissing -BudgetName 'MySubscriptionA-Budget'
Updates the existing budget named 'MySubscriptionA-Budget' for 'MySubscriptionA', or creates it (as a Monthly budget) if it does not already exist.
The name or name/s of the Subscriptions to update the budget for. If not specified all subscriptions available in the current context will be used.
Type: String[]
Parameter Sets: (All)
Aliases: Name, Subscription
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe name of a specific budget to update (or create, when used with -CreateIfMissing). If not specified, the first budget found for the subscription is used.
Type: String
Parameter Sets: (All)
Aliases: Budget
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe most recent billing month to include in the spend average, specified as a [datetime] object. Defaults to the previous calendar month, since the current month's spend is typically incomplete.
Type: DateTime
Parameter Sets: (All)
Aliases: Month
Required: False
Position: 3
Default value: (Get-Date).AddMonths(-1)
Accept pipeline input: False
Accept wildcard characters: FalseThe number of billing months (ending with -BillingMonth) to average when calculating the new budget amount. Default: 3.
Type: Int32
Parameter Sets: (All)
Aliases: PrevMonths
Required: False
Position: 4
Default value: 3
Accept pipeline input: False
Accept wildcard characters: FalseA percentage to add on top of the calculated average spend, e.g. specify 10 to set the budget 10% higher than average spend. Can be negative to set the budget below average spend. Default: 0.
Type: Double
Parameter Sets: (All)
Aliases: Buffer
Required: False
Position: 5
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseIf specified, the new budget amount will never be set lower than this value, regardless of the calculated average spend.
Type: Double
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: If no existing budget is found for a subscription, create a new one using -BudgetName (or a generated name if not specified) and -TimeGrain, instead of skipping that subscription.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThe time grain to use when creating a new budget with -CreateIfMissing. Default: Monthly.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: Monthly
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: Return an object describing the budget change made (or that would be made, with -WhatIf) for each subscription.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).