Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into users/krbar/appInsightsCommonTypes
  • Loading branch information
krbar committed Nov 12, 2024
2 parents 17e6391 + 9bd6587 commit c4f431a
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/platform.ossf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/upload-sarif@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
sarif_file: results.sarif
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 c4f431a

Please sign in to comment.