diff --git a/src/deployment/azuredeploy.bicep b/src/deployment/azuredeploy.bicep index af4fdf63b..a0532305e 100644 --- a/src/deployment/azuredeploy.bicep +++ b/src/deployment/azuredeploy.bicep @@ -62,6 +62,17 @@ resource scalesetIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018 location: location } +module operationalInsights 'bicep-templates/operational-insights.bicep' = { + name: 'operational-insights' + params: { + name: name + location: location + log_retention: log_retention + owner: owner + workbookData: workbookData + } +} + module serverFarms 'bicep-templates/server-farms.bicep' = { name: 'server-farms' params: { @@ -138,17 +149,8 @@ module autoscaleSettings 'bicep-templates/autoscale-settings.bicep' = { location: location server_farm_id: serverFarms.outputs.id owner: owner - } -} - -module operationalInsights 'bicep-templates/operational-insights.bicep' = { - name: 'operational-insights' - params: { - name: name - location: location - log_retention: log_retention - owner: owner - workbookData: workbookData + workspaceId: operationalInsights.outputs.workspaceId + logRetention: log_retention } } @@ -373,7 +375,6 @@ module netFunctionSettings 'bicep-templates/function-settings.bicep' = { ] } - output fuzz_storage string = storage.outputs.FuzzId output fuzz_name string = storage.outputs.FuzzName output fuzz_key string = storage.outputs.FuzzKey diff --git a/src/deployment/bicep-templates/autoscale-settings.bicep b/src/deployment/bicep-templates/autoscale-settings.bicep index 01b8c60b8..88650661c 100644 --- a/src/deployment/bicep-templates/autoscale-settings.bicep +++ b/src/deployment/bicep-templates/autoscale-settings.bicep @@ -1,6 +1,8 @@ param location string param server_farm_id string param owner string +param workspaceId string +param logRetention int var autoscale_name = 'onefuzz-autoscale-${uniqueString(resourceGroup().id)}' @@ -28,16 +30,16 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { metricResourceUri: server_farm_id operator: 'GreaterThanOrEqual' statistic: 'Average' - threshold: 20 + threshold: 50 timeAggregation: 'Average' timeGrain: 'PT1M' - timeWindow: 'PT1M' + timeWindow: 'PT10M' } scaleAction: { - cooldown: 'PT1M' + cooldown: 'PT10M' direction: 'Increase' type: 'ChangeCount' - value: '5' + value: '1' } } { @@ -46,13 +48,13 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { metricResourceUri: server_farm_id operator: 'LessThan' statistic: 'Average' - threshold: 20 + threshold: 25 timeAggregation:'Average' timeGrain: 'PT1M' - timeWindow: 'PT1M' + timeWindow: 'PT10M' } scaleAction: { - cooldown: 'PT5M' + cooldown: 'PT10M' direction: 'Decrease' type: 'ChangeCount' value: '1' @@ -67,3 +69,21 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { OWNER: owner } } + +resource functionDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { + name: 'functionDiagnosticSettings' + scope: autoscaleSettings + properties: { + logs: [ + { + categoryGroup: 'allLogs' + enabled: true + retentionPolicy: { + days: logRetention + enabled: true + } + } + ] + workspaceId: workspaceId + } +} diff --git a/src/deployment/bicep-templates/operational-insights.bicep b/src/deployment/bicep-templates/operational-insights.bicep index 108671b67..179b0edcd 100644 --- a/src/deployment/bicep-templates/operational-insights.bicep +++ b/src/deployment/bicep-templates/operational-insights.bicep @@ -165,3 +165,4 @@ resource insightsWorkbooks 'Microsoft.Insights/workbooks@2021-08-01' = { output monitorAccountName string = monitorAccountName output appInsightsAppId string = insightsComponents.properties.AppId output appInsightsInstrumentationKey string = insightsComponents.properties.InstrumentationKey +output workspaceId string = resourceId('Microsoft.OperationalInsights/workspaces', monitorAccountName) diff --git a/src/deployment/bicep-templates/server-farms.bicep b/src/deployment/bicep-templates/server-farms.bicep index b4453832e..a7ecc4608 100644 --- a/src/deployment/bicep-templates/server-farms.bicep +++ b/src/deployment/bicep-templates/server-farms.bicep @@ -20,5 +20,4 @@ resource serverFarms 'Microsoft.Web/serverfarms@2021-03-01' = { } } - output id string = serverFarms.id