From 98c2960b2d1a9ed0ea83ecbf26533444ce1f9036 Mon Sep 17 00:00:00 2001 From: Noah Harper Date: Thu, 7 Jul 2022 15:22:39 -0700 Subject: [PATCH 1/5] Update Function Scaling Policy and Diagnostic Settings. --- src/deployment/azuredeploy.bicep | 25 ++++++++++--------- .../bicep-templates/autoscale-settings.bicep | 20 +++++++++++++++ .../operational-insights.bicep | 1 + .../bicep-templates/server-farms.bicep | 1 - 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/deployment/azuredeploy.bicep b/src/deployment/azuredeploy.bicep index af4fdf63b4..a0532305eb 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 01b8c60b8d..74c0fe8788 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)}' @@ -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 108671b675..179b0edcd1 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 b4453832e1..a7ecc46088 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 From 6c55d21fd5790bdf0c65bc2d51ddd7262cc0c94d Mon Sep 17 00:00:00 2001 From: Noah Harper Date: Thu, 7 Jul 2022 15:29:05 -0700 Subject: [PATCH 2/5] Adding changes to scaling policy --- src/deployment/bicep-templates/autoscale-settings.bicep | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/deployment/bicep-templates/autoscale-settings.bicep b/src/deployment/bicep-templates/autoscale-settings.bicep index 74c0fe8788..43d270d7be 100644 --- a/src/deployment/bicep-templates/autoscale-settings.bicep +++ b/src/deployment/bicep-templates/autoscale-settings.bicep @@ -30,7 +30,7 @@ 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' @@ -39,7 +39,7 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { cooldown: 'PT1M' direction: 'Increase' type: 'ChangeCount' - value: '5' + value: '1' } } { @@ -48,7 +48,7 @@ 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' From 09235fc3d20e80369dcbca01e36356e8ebdbf422 Mon Sep 17 00:00:00 2001 From: Noah Harper Date: Thu, 7 Jul 2022 15:38:00 -0700 Subject: [PATCH 3/5] UPdating cooldown. --- src/deployment/bicep-templates/autoscale-settings.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deployment/bicep-templates/autoscale-settings.bicep b/src/deployment/bicep-templates/autoscale-settings.bicep index 43d270d7be..c996b9b1b2 100644 --- a/src/deployment/bicep-templates/autoscale-settings.bicep +++ b/src/deployment/bicep-templates/autoscale-settings.bicep @@ -36,7 +36,7 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { timeWindow: 'PT1M' } scaleAction: { - cooldown: 'PT1M' + cooldown: 'PT10M' direction: 'Increase' type: 'ChangeCount' value: '1' From 9edf545f75539a88052bbae8ac66adb0d11622db Mon Sep 17 00:00:00 2001 From: Noah Harper Date: Thu, 7 Jul 2022 15:41:09 -0700 Subject: [PATCH 4/5] Changing time windows. --- src/deployment/bicep-templates/autoscale-settings.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deployment/bicep-templates/autoscale-settings.bicep b/src/deployment/bicep-templates/autoscale-settings.bicep index c996b9b1b2..6be33a18dd 100644 --- a/src/deployment/bicep-templates/autoscale-settings.bicep +++ b/src/deployment/bicep-templates/autoscale-settings.bicep @@ -33,7 +33,7 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { threshold: 50 timeAggregation: 'Average' timeGrain: 'PT1M' - timeWindow: 'PT1M' + timeWindow: 'PT10M' } scaleAction: { cooldown: 'PT10M' @@ -51,7 +51,7 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { threshold: 25 timeAggregation:'Average' timeGrain: 'PT1M' - timeWindow: 'PT1M' + timeWindow: 'PT10M' } scaleAction: { cooldown: 'PT5M' From 3adf0a2672c2d162c7eeadc786e1b172024f255d Mon Sep 17 00:00:00 2001 From: Noah Harper Date: Thu, 7 Jul 2022 16:00:35 -0700 Subject: [PATCH 5/5] Updating duration. --- src/deployment/bicep-templates/autoscale-settings.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deployment/bicep-templates/autoscale-settings.bicep b/src/deployment/bicep-templates/autoscale-settings.bicep index 6be33a18dd..88650661cc 100644 --- a/src/deployment/bicep-templates/autoscale-settings.bicep +++ b/src/deployment/bicep-templates/autoscale-settings.bicep @@ -54,7 +54,7 @@ resource autoscaleSettings 'Microsoft.Insights/autoscalesettings@2015-04-01' = { timeWindow: 'PT10M' } scaleAction: { - cooldown: 'PT5M' + cooldown: 'PT10M' direction: 'Decrease' type: 'ChangeCount' value: '1'