Skip to content

feat: Add per-notification operator/thresholdType control for Consumption Budget modules#7132

Open
segraef with Copilot wants to merge 12 commits into
mainfrom
copilot/avm-module-fine-control-thresholds
Open

feat: Add per-notification operator/thresholdType control for Consumption Budget modules#7132
segraef with Copilot wants to merge 12 commits into
mainfrom
copilot/avm-module-fine-control-thresholds

Conversation

Copilot AI commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This change adds additive, per-notification control for budget alerts so a single budget can mix Actual and Forecasted notifications with independent operators. Existing behavior is preserved by keeping the current thresholds + thresholdType path as fallback when notifications is not provided.

  • Module contract changes (all scopes: sub/mg/rg)

    • Added exported notificationType user-defined type with operator, bounded threshold, and thresholdType.
    • Added optional @maxLength(5) param notifications notificationType[]?.
    • Marked thresholds and thresholdType descriptions as deprecated in favor of notifications.
  • Notification composition logic

    • When notifications is non-empty, resource notifications are built from it.
    • Otherwise, notifications are derived from legacy thresholds + operator + thresholdType to keep compatibility.
  • Generated module artifacts

    • Regenerated scoped README.md and main.json files for sub-scope, mg-scope, and rg-scope via Set-AVMModule.
  • Versioning and CHANGELOG

    • Bumped the MINOR version in version.json from 0.1 to 0.2 for all three scopes (sub-scope, mg-scope, rg-scope).
    • Added a ## 0.2.0 section to each scope's CHANGELOG.md describing the new notifications parameter. This resolves the Module Compliance failure requiring the CHANGELOG to contain a section for the new module version.
param notifications notificationType[]?

var notificationSettings = !empty(notifications ?? []) ? notifications! : notificationsFromThresholds

var notificationsArray = [
  for notification in notificationSettings: {
    '${notification.thresholdType}_${notification.operator}_${notification.threshold}_Percentage': {
      enabled: true
      operator: notification.operator
      threshold: notification.threshold
      thresholdType: notification.thresholdType
    }
  }
]

Pipeline Reference

Pipeline
avm.res.consumption.budget

Type of Change

  • Azure Verified Module updates:
    • Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in version.json:
    • Feature update backwards compatible feature updates, and I have bumped the MINOR version in version.json.
    • Breaking changes and I have bumped the MAJOR version in version.json.
    • Update to documentation
  • Update to CI Environment or utilities (Non-module affecting changes)

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • I have run Set-AVMModule locally to generate the supporting module files.
  • My corresponding pipelines / checks run clean and green without any errors or warnings
  • I have updated the module's CHANGELOG.md file with an entry for the next version

Copilot AI linked an issue Jun 5, 2026 that may be closed by this pull request
1 task
@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs: Triage 🔍 Maintainers need to triage still Type: AVM 🅰️ ✌️ Ⓜ️ This is an AVM related issue labels Jun 5, 2026
Copilot AI and others added 2 commits June 5, 2026 00:25
Co-authored-by: segraef <19261257+segraef@users.noreply.github.com>
Co-authored-by: segraef <19261257+segraef@users.noreply.github.com>
Copilot AI changed the title [WIP] Add fine control for notification thresholds in budget Add per-notification operator/thresholdType control for Consumption Budget modules Jun 5, 2026
Copilot AI requested a review from segraef June 5, 2026 00:34
Copilot AI changed the title Add per-notification operator/thresholdType control for Consumption Budget modules feat: Add per-notification operator/thresholdType control for Consumption Budget modules Jun 5, 2026
@segraef segraef marked this pull request as ready for review June 5, 2026 09:24
@segraef segraef requested review from a team as code owners June 5, 2026 09:24
@segraef

segraef commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Co-authored-by: segraef <19261257+segraef@users.noreply.github.com>

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot have a look at https://github.com/Azure/bicep-registry-modules/actions/runs/27008032579/job/79704656273 in this regard.

The job failed on the CHANGELOG compliance test: [consumption/budget/rg-scope] and [sub-scope] required a ## 0.1.1 section because the module had changes but version.json wasn't bumped.

Since this PR adds a feature (the notifications parameter), I bumped the MINOR version in version.json from 0.1 to 0.2 and added a ## 0.2.0 section to the CHANGELOG for all three scopes (rg/sub/mg). The compliance test now expects and finds ## 0.2.0.

@segraef segraef temporarily deployed to avm-validation June 10, 2026 02:32 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 02:32 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 02:32 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 06:44 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 06:44 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 06:44 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 06:44 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef temporarily deployed to avm-validation June 10, 2026 09:38 — with GitHub Actions Inactive
@segraef segraef enabled auto-merge (squash) June 10, 2026 10:25

@export()
type notificationType = {
@description('Required. The comparison operator. The operator can be either `EqualTo`, `GreaterThan`, or `GreaterThanOrEqualTo`.')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@description('Required. The comparison operator. The operator can be either `EqualTo`, `GreaterThan`, or `GreaterThanOrEqualTo`.')
@description('Required. The comparison operator.')

Redundant information that is anyways suggested automatically to the user.

@minValue(1)
@maxValue(1000)
threshold: int
@description('Required. The type of threshold to use for the budget. The threshold type can be either `Actual` or `Forecasted`.')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@description('Required. The type of threshold to use for the budget. The threshold type can be either `Actual` or `Forecasted`.')
@description('Required. The type of threshold to use for the budget.')

Redundant information that is anyways suggested automatically to the user.

targetScope = 'managementGroup'

@export()
type notificationType = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually group all types in a // Definitions // section at the bottom of the file to somewhat imply order 😄

targetScope = 'subscription'

@export()
type notificationType = {

@AlexanderSehr AlexanderSehr Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as per mg-scope


@maxLength(5)
@description('Optional. Percent thresholds of budget for when to get a notification. Can be up to 5 thresholds, where each must be between 1 and 1000.')
@description('Optional. Deprecated: use `notifications` for per-threshold control. Percent thresholds of budget for when to get a notification. Can be up to 5 thresholds, where each must be between 1 and 1000.')

@AlexanderSehr AlexanderSehr Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove it? We're pre 1.0 and can/should upgrade the module version accordingly.
That's why we have a breaking change section in which we can also explain the migration/upgrade strategy 😉

'Forecasted'
])
@description('Optional. The type of threshold to use for the budget. The threshold type can be either `Actual` or `Forecasted`.')
@description('Optional. Deprecated: use `notifications` for per-threshold control. The type of threshold to use for the budget. The threshold type can be either `Actual` or `Forecasted`.')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for 'thresholds'

Comment on lines +5 to +6
type notificationType = {
@description('Required. The comparison operator. The operator can be either `EqualTo`, `GreaterThan`, or `GreaterThanOrEqualTo`.')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as per mg-scope

@AlexanderSehr

Copy link
Copy Markdown
Collaborator

ping @segraef

@AlexanderSehr AlexanderSehr added the Needs: Author Feedback 👂 Awaiting feedback from the issue/PR author label Jul 6, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Status: No Recent Activity 💤 When an issue/PR has not been modified for X amount of days label Jul 12, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown

Important

@copilot, this issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days.

Tip

To prevent further actions to take effect, one of the following conditions must be met:

  • The author must respond in a comment within 3 days of this comment.
  • The "Status: No Recent Activity 💤" label must be removed.
  • If applicable, the "Status: Long Term ⏳" or the "Needs: Module Owner 📣" label must be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Author Feedback 👂 Awaiting feedback from the issue/PR author Needs: Triage 🔍 Maintainers need to triage still Status: No Recent Activity 💤 When an issue/PR has not been modified for X amount of days Type: AVM 🅰️ ✌️ Ⓜ️ This is an AVM related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AVM Module Issue]: Fine control for notification thresholds in budget

3 participants