Skip to content

Commit dbf6bf5

Browse files
committed
Transition to Log Analytics style App Insights
1 parent 348ef6e commit dbf6bf5

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

deploy/bicep/main.bicep

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ param leaseContainerName string
55
param userManagedIdentityName string
66
param location string
77

8+
param logAnalyticsWorkspaceName string
89
param appInsightsName string
910
param appInsightsDailyCapGb int
1011
param actionGroupName string
@@ -56,26 +57,30 @@ resource userManagedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2
5657
location: location
5758
}
5859

59-
resource appInsights 'Microsoft.Insights/components@2015-05-01' = {
60+
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
61+
name: logAnalyticsWorkspaceName
62+
location: location
63+
properties: {
64+
features: {
65+
immediatePurgeDataOn30Days: true
66+
}
67+
sku: {
68+
name: 'PerGB2018'
69+
}
70+
retentionInDays: 30
71+
workspaceCapping: {
72+
dailyQuotaGb: appInsightsDailyCapGb
73+
}
74+
}
75+
}
76+
77+
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
6078
name: appInsightsName
6179
location: location
6280
kind: 'web'
6381
properties: {
6482
Application_Type: 'web'
65-
}
66-
67-
// This produces a warning due to limited type definitions, but works.
68-
// See: https://github.com/Azure/bicep/issues/784#issuecomment-830997209
69-
#disable-next-line BCP081
70-
resource billing 'CurrentBillingFeatures' = {
71-
name: 'Basic'
72-
properties: {
73-
CurrentBillingFeatures: 'Basic'
74-
DataVolumeCap: {
75-
Cap: appInsightsDailyCapGb
76-
WarningThreshold: 90
77-
}
78-
}
83+
WorkspaceResourceId: logAnalyticsWorkspace.id
7984
}
8085
}
8186

deploy/config/ev2-dev-usnc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"WorkerCountPerPlan": 1,
1515
"WorkerPlanCount": 1,
1616
"WorkerLogLevel": "Warning",
17+
"LogAnalyticsWorkspaceName": "ev2-dev-usnc-insights-la",
1718
"AppInsightsName": "ev2-dev-usnc-insights-ai",
1819
"AppInsightsDailyCapGb": 1,
1920
"ActionGroupName": "ev2-dev-usnc",

deploy/scripts/NuGet.Insights.psm1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class ResourceSettings {
88
[ValidateNotNullOrEmpty()]
99
[string]$Location
1010

11+
[ValidateNotNullOrEmpty()]
12+
[string]$LogAnalyticsWorkspaceName
13+
1114
[ValidateNotNullOrEmpty()]
1215
[string]$AppInsightsName
1316

@@ -168,6 +171,7 @@ class ResourceSettings {
168171
}
169172

170173
Set-OrDefault Location "West US 2"
174+
Set-OrDefault LogAnalyticsWorkspaceName "NuGetInsights-$StampName"
171175
Set-OrDefault AppInsightsName "NuGetInsights-$StampName"
172176
Set-OrDefault AppInsightsDailyCapGb 1
173177
Set-OrDefault ActionGroupName "NuGetInsights-$StampName"
@@ -534,6 +538,7 @@ function New-MainParameters(
534538
actionGroupShortName = $ResourceSettings.ActionGroupShortName;
535539
alertEmail = $ResourceSettings.AlertEmail;
536540
alertPrefix = $ResourceSettings.AlertPrefix;
541+
logAnalyticsWorkspaceName = $ResourceSettings.LogAnalyticsWorkspaceName;
537542
appInsightsDailyCapGb = $ResourceSettings.AppInsightsDailyCapGb;
538543
appInsightsName = $ResourceSettings.AppInsightsName;
539544
deploymentLabel = $DeploymentLabel;

0 commit comments

Comments
 (0)