Skip to content

Commit

Permalink
avm/res/dev-ops-infrastructure/pool: removed preview API and added …
Browse files Browse the repository at this point in the history
…daysData UDT for user-friendly input (#3751)

## Description

This pull requests:

- Updates the API version to non-preview
- Adds a user-defined type for daysData to make the input user-friendly
- Updates WAF deployment test
- Adds `formattedDaysData` to convert user input to actual input
required by API

Tagging module owners: @elizatargithub7 @surajguptha

## Pipeline Reference

| Pipeline |
| -------- |
|
[![avm.res.dev-ops-infrastructure.pool](https://github.com/johnlokerse/bicep-registry-modules/actions/workflows/avm.res.dev-ops-infrastructure.pool.yml/badge.svg?branch=johnlokerse%2Fimprove-mdp-daysdata)](https://github.com/johnlokerse/bicep-registry-modules/actions/workflows/avm.res.dev-ops-infrastructure.pool.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ ] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [x] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [x] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
johnlokerse authored Nov 10, 2024
1 parent 7e8e250 commit c0df1b1
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 190 deletions.
148 changes: 44 additions & 104 deletions avm/res/dev-ops-infrastructure/pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This module deploys the Managed DevOps Pool resource.
| :-- | :-- |
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.DevOpsInfrastructure/pools` | [2024-04-04-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DevOpsInfrastructure/2024-04-04-preview/pools) |
| `Microsoft.DevOpsInfrastructure/pools` | [2024-10-19](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DevOpsInfrastructure/2024-10-19/pools) |
| `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) |

## Usage examples
Expand Down Expand Up @@ -182,26 +182,24 @@ module pool 'br/public:avm/res/dev-ops-infrastructure/pool:<version>' = {
agentProfile: {
kind: 'Stateless'
resourcePredictions: {
daysData: [
{
'09:00:00': 1
'17:00:00': 0
daysData: {
friday: {
endAgentCount: 0
endTime: '17:00:00'
startAgentCount: 1
startTime: '09:00:00'
}
{}
{}
{}
{
'09:00:00': 1
'17:00:00': 0
monday: {
endAgentCount: 0
endTime: '17:00:00'
startAgentCount: 1
startTime: '09:00:00'
}
{}
{}
]
timeZone: 'Central Europe Standard Time'
}
timeZone: 'UTC'
}
resourcePredictionsProfile: {
kind: 'Automatic'
predictionPreference: 'Balanced'
kind: 'Manual'
}
}
concurrency: 1
Expand Down Expand Up @@ -293,26 +291,24 @@ module pool 'br/public:avm/res/dev-ops-infrastructure/pool:<version>' = {
"value": {
"kind": "Stateless",
"resourcePredictions": {
"daysData": [
{
"09:00:00": 1,
"17:00:00": 0
},
{},
{},
{},
{
"09:00:00": 1,
"17:00:00": 0
"daysData": {
"friday": {
"endAgentCount": 0,
"endTime": "17:00:00",
"startAgentCount": 1,
"startTime": "09:00:00"
},
{},
{}
],
"timeZone": "Central Europe Standard Time"
"monday": {
"endAgentCount": 0,
"endTime": "17:00:00",
"startAgentCount": 1,
"startTime": "09:00:00"
}
},
"timeZone": "UTC"
},
"resourcePredictionsProfile": {
"kind": "Automatic",
"predictionPreference": "Balanced"
"kind": "Manual"
}
}
},
Expand Down Expand Up @@ -426,26 +422,24 @@ using 'br/public:avm/res/dev-ops-infrastructure/pool:<version>'
param agentProfile = {
kind: 'Stateless'
resourcePredictions: {
daysData: [
{
'09:00:00': 1
'17:00:00': 0
daysData: {
friday: {
endAgentCount: 0
endTime: '17:00:00'
startAgentCount: 1
startTime: '09:00:00'
}
{}
{}
{}
{
'09:00:00': 1
'17:00:00': 0
monday: {
endAgentCount: 0
endTime: '17:00:00'
startAgentCount: 1
startTime: '09:00:00'
}
{}
{}
]
timeZone: 'Central Europe Standard Time'
}
timeZone: 'UTC'
}
resourcePredictionsProfile: {
kind: 'Automatic'
predictionPreference: 'Balanced'
kind: 'Manual'
}
}
param concurrency = 1
Expand Down Expand Up @@ -537,24 +531,6 @@ module pool 'br/public:avm/res/dev-ops-infrastructure/pool:<version>' = {
// Required parameters
agentProfile: {
kind: 'Stateless'
resourcePredictions: {
daysData: [
{
'09:00:00': 1
'17:00:00': 0
}
{}
{}
{}
{
'09:00:00': 1
'17:00:00': 0
}
{}
{}
]
timeZone: 'Central Europe Standard Time'
}
resourcePredictionsProfile: {
kind: 'Automatic'
predictionPreference: 'Balanced'
Expand Down Expand Up @@ -607,24 +583,6 @@ module pool 'br/public:avm/res/dev-ops-infrastructure/pool:<version>' = {
"agentProfile": {
"value": {
"kind": "Stateless",
"resourcePredictions": {
"daysData": [
{
"09:00:00": 1,
"17:00:00": 0
},
{},
{},
{},
{
"09:00:00": 1,
"17:00:00": 0
},
{},
{}
],
"timeZone": "Central Europe Standard Time"
},
"resourcePredictionsProfile": {
"kind": "Automatic",
"predictionPreference": "Balanced"
Expand Down Expand Up @@ -691,24 +649,6 @@ using 'br/public:avm/res/dev-ops-infrastructure/pool:<version>'
// Required parameters
param agentProfile = {
kind: 'Stateless'
resourcePredictions: {
daysData: [
{
'09:00:00': 1
'17:00:00': 0
}
{}
{}
{}
{
'09:00:00': 1
'17:00:00': 0
}
{}
{}
]
timeZone: 'Central Europe Standard Time'
}
resourcePredictionsProfile: {
kind: 'Automatic'
predictionPreference: 'Balanced'
Expand Down
108 changes: 85 additions & 23 deletions avm/res/dev-ops-infrastructure/pool/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ var identity = !empty(managedIdentities)
}
: null

var formattedDaysData = !empty(agentProfile.?resourcePredictions.?daysData)
? map(
['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
day =>
contains(agentProfile.resourcePredictions.daysData, day)
? {
'${agentProfile.resourcePredictions.daysData[day].startTime}': agentProfile.resourcePredictions.daysData[day].startAgentCount
'${agentProfile.resourcePredictions.daysData[day].endTime}': agentProfile.resourcePredictions.daysData[day].endAgentCount
}
: {}
)
: null

#disable-next-line no-deployments-resources
resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableTelemetry) {
name: '46d3xbcp.res.devopsinfrastructure-pool.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}'
Expand All @@ -133,13 +146,36 @@ resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableT
}
}

resource managedDevOpsPool 'Microsoft.DevOpsInfrastructure/pools@2024-04-04-preview' = {
resource managedDevOpsPool 'Microsoft.DevOpsInfrastructure/pools@2024-10-19' = {
name: name
location: location
tags: tags
identity: identity
properties: {
agentProfile: agentProfile
// agentProfile: agentProfile
agentProfile: agentProfile.kind == 'Stateful'
? {
kind: 'Stateful'
maxAgentLifetime: agentProfile.maxAgentLifetime
gracePeriodTimeSpan: agentProfile.gracePeriodTimeSpan
resourcePredictions: !empty(agentProfile.?resourcePredictions)
? {
timeZone: agentProfile.?resourcePredictions.timeZone
daysData: formattedDaysData
}
: null
resourcePredictionsProfile: agentProfile.?resourcePredictionsProfile
}
: {
kind: 'Stateless'
resourcePredictions: !empty(agentProfile.?resourcePredictions)
? {
timeZone: agentProfile.?resourcePredictions.timeZone
daysData: formattedDaysData
}
: null
resourcePredictionsProfile: agentProfile.?resourcePredictionsProfile
}
devCenterProjectResourceId: devCenterProjectResourceId
fabricProfile: {
sku: {
Expand Down Expand Up @@ -363,7 +399,13 @@ type agentStatefulType = {
gracePeriodTimeSpan: string

@description('Optional. Defines pool buffer/stand-by agents.')
resourcePredictions: object?
resourcePredictions: {
@description('Required. The time zone in which the daysData is provided. To see the list of available time zones, see: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones or via PowerShell command `(Get-TimeZone -ListAvailable).StandardName`.')
timeZone: string

@description('Optional. The number of agents needed at a specific time.')
daysData: daysDataType
}?

@discriminator('kind')
@description('Optional. Determines how the stand-by scheme should be provided.')
Expand All @@ -381,26 +423,7 @@ type agentStatelessType = {
timeZone: string

@description('Optional. The number of agents needed at a specific time.')
@metadata({
example: '''
[
{ // Monday
'09:00': 5
'22:00': 0
}
{} // Tuesday
{} // Wednesday
{} // Thursday
{ // Friday
'09:00': 5
'22:00': 0
}
{} // Saturday
{} // Sunday
]
'''
})
daysData: object[]?
daysData: daysDataType
}?

@discriminator('kind')
Expand Down Expand Up @@ -501,3 +524,42 @@ type managedIdentitiesType = {
@description('Optional. The resource ID(s) to assign to the resource.')
userAssignedResourceIds: string[]?
}?

@export()
type standbyAgentsConfigType = {
@description('Required. The time at which the agents are needed.')
startTime: string

@description('Required. The time at which the agents are no longer needed.')
endTime: string

@description('Required. The number of agents needed at the start time.')
startAgentCount: int

@description('Required. The number of agents needed at the end time.')
endAgentCount: int
}?

@export()
type daysDataType = {
@description('Optional. The number of agents needed at a specific time for Monday.')
monday: standbyAgentsConfigType

@description('Optional. The number of agents needed at a specific time for Tuesday.')
tuesday: standbyAgentsConfigType

@description('Optional. The number of agents needed at a specific time for Wednesday.')
wednesday: standbyAgentsConfigType

@description('Optional. The number of agents needed at a specific time for Thursday.')
thursday: standbyAgentsConfigType

@description('Optional. The number of agents needed at a specific time for Friday.')
friday: standbyAgentsConfigType

@description('Optional. The number of agents needed at a specific time for Saturday.')
saturday: standbyAgentsConfigType

@description('Optional. The number of agents needed at a specific time for Sunday.')
sunday: standbyAgentsConfigType
}?
Loading

0 comments on commit c0df1b1

Please sign in to comment.