Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Update Function Scaling Policy and Diagnostic Settings. #2140

Merged
merged 7 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
25 changes: 13 additions & 12 deletions src/deployment/azuredeploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
Expand Down
34 changes: 27 additions & 7 deletions src/deployment/bicep-templates/autoscale-settings.bicep
Original file line number Diff line number Diff line change
@@ -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)}'

Expand Down Expand Up @@ -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'
}
}
{
Expand All @@ -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'
Expand All @@ -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
}
}
1 change: 1 addition & 0 deletions src/deployment/bicep-templates/operational-insights.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion src/deployment/bicep-templates/server-farms.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ resource serverFarms 'Microsoft.Web/serverfarms@2021-03-01' = {
}
}


output id string = serverFarms.id