Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ms.consumption.budgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ jobs:
- name: 'Using test file [${{ matrix.moduleTestFilePaths }}]'
uses: ./.github/actions/templates/validateModuleDeployment
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}'
templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}'
location: '${{ env.location }}'
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
targetScope = 'subscription'

// ========== //
// Parameters //
// ========== //
@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
param serviceShort string = 'cbcom'

// ============== //
// Test Execution //
// ============== //

module testDeployment '../../deploy.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
name: '<<namePrefix>>${serviceShort}001'
amount: 500
contactEmails: [
'dummy@contoso.com'
]
thresholds: [
50
75
90
100
110
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
targetScope = 'subscription'

// ========== //
// Parameters //
// ========== //
@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
param serviceShort string = 'cbmin'

// ============== //
// Test Execution //
// ============== //

module testDeployment '../../deploy.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
name: '<<namePrefix>>${serviceShort}001'
amount: 500
contactEmails: [
'dummy@contoso.com'
]
}
}
26 changes: 0 additions & 26 deletions modules/Microsoft.Consumption/budgets/.test/parameters.json

This file was deleted.

6 changes: 3 additions & 3 deletions modules/Microsoft.Consumption/budgets/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ param thresholds array = [
110
]

@description('Optional. The list of email addresses to send the budget notification to when the thresholds are exceeded.')
@description('Conditional. The list of email addresses to send the budget notification to when the thresholds are exceeded. Required if neither `contactRoles` nor `actionGroups` was provided.')
param contactEmails array = []

@description('Optional. The list of contact roles to send the budget notification to when the thresholds are exceeded.')
@description('Conditional. The list of contact roles to send the budget notification to when the thresholds are exceeded. Required if neither `contactEmails` nor `actionGroups` was provided.')
param contactRoles array = []

@description('Optional. List of action group resource IDs that will receive the alert.')
@description('Conditional. List of action group resource IDs that will receive the alert. Required if neither `contactEmails` nor `contactEmails` was provided.')
param actionGroups array = []

@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).')
Expand Down
71 changes: 64 additions & 7 deletions modules/Microsoft.Consumption/budgets/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ This module deploys budgets for subscriptions.
| `amount` | int | The total amount of cost or usage to track with the budget. |
| `name` | string | The name of the budget. |

**Conditional parameters**
| Parameter Name | Type | Description |
| :-- | :-- | :-- |
| `actionGroups` | array | List of action group resource IDs that will receive the alert. Required if neither `contactEmails` nor `contactEmails` was provided. |
| `contactEmails` | array | The list of email addresses to send the budget notification to when the thresholds are exceeded. Required if neither `contactRoles` nor `actionGroups` was provided. |
| `contactRoles` | array | The list of contact roles to send the budget notification to when the thresholds are exceeded. Required if neither `contactEmails` nor `actionGroups` was provided. |

**Optional parameters**
| Parameter Name | Type | Default Value | Allowed Values | Description |
| :-- | :-- | :-- | :-- | :-- |
| `actionGroups` | array | `[]` | | List of action group resource IDs that will receive the alert. |
| `category` | string | `'Cost'` | `[Cost, Usage]` | The category of the budget, whether the budget tracks cost or usage. |
| `contactEmails` | array | `[]` | | The list of email addresses to send the budget notification to when the thresholds are exceeded. |
| `contactRoles` | array | `[]` | | The list of contact roles to send the budget notification to when the thresholds are exceeded. |
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). |
| `endDate` | string | `''` | | The end date for the budget. If not provided, it will default to 10 years from the start date. |
| `location` | string | `[deployment().location]` | | Location deployment metadata. |
Expand All @@ -57,19 +61,19 @@ The following module usage examples are retrieved from the content of the files
>**Note**: The name of each example is based on the name of the file from which it is taken.
>**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order.

<h3>Example 1: Parameters</h3>
<h3>Example 1: Common</h3>

<details>

<summary>via Bicep module</summary>

```bicep
module budgets './Microsoft.Consumption/budgets/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-Budgets'
name: '${uniqueString(deployment().name)}-test-cbcom'
params: {
// Required parameters
amount: 500
name: 'Monthly-Cost-Budget'
name: '<<namePrefix>>cbcom001'
// Non-required parameters
contactEmails: [
'dummy@contoso.com'
Expand Down Expand Up @@ -102,7 +106,7 @@ module budgets './Microsoft.Consumption/budgets/deploy.bicep' = {
"value": 500
},
"name": {
"value": "Monthly-Cost-Budget"
"value": "<<namePrefix>>cbcom001"
},
// Non-required parameters
"contactEmails": {
Expand All @@ -125,3 +129,56 @@ module budgets './Microsoft.Consumption/budgets/deploy.bicep' = {

</details>
<p>

<h3>Example 2: Min</h3>

<details>

<summary>via Bicep module</summary>

```bicep
module budgets './Microsoft.Consumption/budgets/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-test-cbmin'
params: {
// Required parameters
amount: 500
name: '<<namePrefix>>cbmin001'
// Non-required parameters
contactEmails: [
'dummy@contoso.com'
]
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"amount": {
"value": 500
},
"name": {
"value": "<<namePrefix>>cbmin001"
},
// Non-required parameters
"contactEmails": {
"value": [
"dummy@contoso.com"
]
}
}
}
```

</details>
<p>