Skip to content

Commit a9391a2

Browse files
committed
update log analytics and app insights avm
1 parent c2c355a commit a9391a2

4 files changed

Lines changed: 152 additions & 35 deletions

File tree

infra/main.bicep

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ module bicepOwnerRoleAssignment 'modules/role_assignment.bicep' = {
131131
module avmKeyVault './modules/key-vault.bicep' = {
132132
name: format(deployment_param.resource_name_format_string, abbrs.security.keyVault)
133133
params: {
134+
deployment_param: deployment_param
134135
keyVaultParams: {
135136
keyvaultName: '${abbrs.security.keyVault}${deployment_param.solution_prefix}'
136137
location: deployment_param.resource_group_location
@@ -171,41 +172,37 @@ module avmKeyVault './modules/key-vault.bicep' = {
171172
// scope: resourceGroup(resourceGroup().name)
172173
// }
173174

174-
// ========== Application insights ========== //
175-
module avmLogAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0.11.2' = {
176-
name: format(deployment_param.resource_name_format_string, abbrs.managementGovernance.logAnalyticsWorkspace)
177-
params: {
178-
name: '${abbrs.managementGovernance.logAnalyticsWorkspace}${deployment_param.solution_prefix}'
179-
location: deployment_param.resource_group_location
180-
diagnosticSettings: [{ useThisWorkspace: true }]
181-
skuName: 'PerGB2018'
182-
dataRetention: 30
183-
}
184-
}
185-
186-
module avmApplicationInsights 'br/public:avm/res/insights/component:0.6.0' = {
187-
name: format(deployment_param.resource_name_format_string, abbrs.managementGovernance.applicationInsights)
175+
// ========== Application insights and Log Analytics Workspace (AVM module) ========== //
176+
module avmAppInsightsAndLogAnalytics './modules/app-insights.bicep' = {
177+
name: format(deployment_param.resource_name_format_string, 'ai-law-avm')
188178
params: {
189-
name: '${abbrs.managementGovernance.applicationInsights}${deployment_param.solution_prefix}'
190-
location: deployment_param.resource_group_location
191-
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
192-
retentionInDays: 30
193-
kind: 'web'
194-
disableIpMasking: false
195-
flowType: 'Bluefield'
196-
diagnosticSettings: [{ workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId }]
179+
deployment_param: deployment_param
180+
appInsights_param: {
181+
appInsightsName: '${abbrs.managementGovernance.applicationInsights}${deployment_param.solution_prefix}'
182+
logAnalyticsWorkspaceName: '${abbrs.managementGovernance.logAnalyticsWorkspace}${deployment_param.solution_prefix}'
183+
location: deployment_param.resource_group_location
184+
kind: 'web'
185+
retentionInDays: 30
186+
features: {
187+
searchVersion: 1
188+
}
189+
skuName: 'PerGB2018'
190+
applicationType: 'web'
191+
disableIpMasking: false
192+
disableLocalAuth: false
193+
flowType: 'Bluefield'
194+
forceCustomerStorageForProfiler: false
195+
//ImmediatePurgeDataOn30Days: true
196+
//IngestionMode: 'LogAnalytics'
197+
publicNetworkAccessForIngestion: 'Enabled'
198+
publicNetworkAccessForQuery: 'Disabled'
199+
requestSource: 'rest'
200+
201+
}
197202
}
203+
scope: resourceGroup(resourceGroup().name)
198204
}
199205

200-
// module applicationInsights 'deploy_app_insights.bicep' = {
201-
// name: 'deploy_app_insights'
202-
// params: {
203-
// applicationInsightsName: '${abbrs.managementGovernance.applicationInsights}${solutionPrefix}'
204-
// logAnalyticsWorkspaceName: '${abbrs.managementGovernance.logAnalyticsWorkspace}${solutionPrefix}'
205-
// }
206-
// }
207-
208-
// // ========== Container Registry ========== //
209206
module avmContainerRegistry 'br/public:avm/res/container-registry/registry:0.9.1' = {
210207
name: format(deployment_param.resource_name_format_string, abbrs.containers.containerRegistry)
211208
params: {
@@ -364,7 +361,7 @@ module avmAiServices_storage_hub 'br/public:avm/res/storage/storage-account:0.20
364361
allowSharedKeyAccess: false
365362
diagnosticSettings: [
366363
{
367-
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
364+
workspaceResourceId: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceId
368365
}
369366
]
370367
blobServices: {
@@ -373,7 +370,7 @@ module avmAiServices_storage_hub 'br/public:avm/res/storage/storage-account:0.20
373370
containerDeleteRetentionPoloicyEnabled: false
374371
diagnosticSettings: [
375372
{
376-
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
373+
workspaceResourceId: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceId
377374
}
378375
]
379376
}
@@ -405,7 +402,7 @@ module avmAiHub 'br/public:avm/res/machine-learning-services/workspace:0.12.1' =
405402
associatedKeyVaultResourceId: avmKeyVault.outputs.resourceId
406403
associatedStorageAccountResourceId: avmAiServices_storage_hub.outputs.resourceId
407404
associatedContainerRegistryResourceId: avmContainerRegistry.outputs.resourceId
408-
associatedApplicationInsightsResourceId: avmApplicationInsights.outputs.resourceId
405+
associatedApplicationInsightsResourceId: avmAppInsightsAndLogAnalytics.outputs.applicationInsightsId
409406

410407
kind: 'Hub'
411408
connections: [
@@ -459,6 +456,18 @@ module avmAiProject 'br/public:avm/res/machine-learning-services/workspace:0.12.
459456
// scope: resourceGroup(resourceGroup().name)
460457
// }
461458

459+
//TODO: Remove
460+
461+
module avmLogAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0.11.2' = {
462+
name: 'workspaceDeployment'
463+
params: {
464+
// Required parameters
465+
name: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceName
466+
}
467+
scope: resourceGroup(resourceGroup().name)
468+
}
469+
470+
462471
// ========== Container App Environment ========== //
463472
module avmContainerAppEnv 'br/public:avm/res/app/managed-environment:0.11.1' = {
464473
name: format(deployment_param.resource_name_format_string, abbrs.containers.containerAppsEnvironment)
@@ -473,7 +482,7 @@ module avmContainerAppEnv 'br/public:avm/res/app/managed-environment:0.11.1' = {
473482
appLogsConfiguration: {
474483
destination: 'log-analytics'
475484
logAnalyticsConfiguration: {
476-
customerId: avmLogAnalyticsWorkspace.outputs.logAnalyticsWorkspaceId
485+
customerId: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceId
477486
sharedKey: avmLogAnalyticsWorkspace.outputs.primarySharedKey
478487
}
479488
}

infra/modules/app-insights.bicep

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// modules/app-insights-avm.bicep
2+
metadata name = 'AVM Application Insights and Log Analytics Workspace Module'
3+
// AVM-compliant Application Insights and Log Analytics Workspace deployment
4+
// param applicationInsightsName string
5+
// param logAnalyticsWorkspaceName string
6+
// param location string
7+
// param dataRetention int = 30
8+
// param skuName string = 'PerGB2018'
9+
// param kind string = 'web'
10+
// param disableIpMasking bool = false
11+
// param flowType string = 'Bluefield'
12+
13+
import {
14+
app_insights_param_type
15+
default_deployment_param_type
16+
} from './types.bicep'
17+
18+
19+
param appInsights_param app_insights_param_type
20+
param deployment_param default_deployment_param_type
21+
22+
module avmLogAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0.11.2' = {
23+
name: 'deploy_log_analytics_workspace'
24+
params: {
25+
name: appInsights_param.logAnalyticsWorkspaceName
26+
location: appInsights_param.location
27+
skuName: appInsights_param.skuName
28+
dataRetention: appInsights_param.retentionInDays
29+
// features: {
30+
// searchVersion: appInsights_param.features.searchVersion
31+
// }
32+
}
33+
}
34+
35+
module avmApplicationInsights 'br/public:avm/res/insights/component:0.6.0' = {
36+
name: 'deploy_application_insights'
37+
params: {
38+
name: appInsights_param.appInsightsName
39+
location: appInsights_param.location
40+
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
41+
kind: appInsights_param.kind
42+
applicationType: appInsights_param.applicationType
43+
disableIpMasking: appInsights_param.disableIpMasking
44+
disableLocalAuth: appInsights_param.disableLocalAuth
45+
flowType: appInsights_param.flowType
46+
forceCustomerStorageForProfiler: appInsights_param.forceCustomerStorageForProfiler
47+
//immediatePurgeDataOn30Days: false
48+
//IngestionMode: 'LogAnalytics'
49+
publicNetworkAccessForIngestion: appInsights_param.publicNetworkAccessForIngestion
50+
publicNetworkAccessForQuery: appInsights_param.publicNetworkAccessForQuery
51+
requestSource: appInsights_param.requestSource
52+
53+
}
54+
}
55+
56+
output applicationInsightsId string = avmApplicationInsights.outputs.resourceId
57+
output logAnalyticsWorkspaceId string = avmLogAnalyticsWorkspace.outputs.resourceId
58+
output logAnalyticsWorkspaceName string = avmLogAnalyticsWorkspace.outputs.name

infra/modules/parameters.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var deployment_param default_deployment_param_type = {
6161
resource_group_location: resourceGroupLocation
6262
resource_name_prefix: {}
6363
resource_name_format_string: resource_format_string
64+
enable_waf: false // Set to true if you want to enable WAF
6465
}
6566

6667
var ai_deployment ai_deployment_param_type = {

infra/modules/types.bicep

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,52 @@ type key_vault_param_type = {
100100
@description('Enable telemetry for the Key Vault')
101101
enableTelemetry: bool
102102
}
103+
104+
105+
type app_insights_retention_in_days = 30 | 60 | 90 | 120 | 180 | 270 | 365
106+
type app_insights_kind = 'web' | 'other'
107+
type app_insights_applicationType = 'web' | 'other'
108+
type app_insights_flow_type = 'Bluefield' | 'Basic'
109+
type app_insights_sku_name = 'PerGB2018' | 'CapacityReservation' | 'Premium' | 'Standard' | 'Free' | 'PerNode' | 'LACluster' | 'Standalone'
110+
111+
@export()
112+
type app_insights_param_type = {
113+
@description('Name of the Application Insights resource')
114+
appInsightsName: string
115+
@description('Location for the Application Insights and Log Analytics Workspace resources')
116+
location: string
117+
// @description('Workspace resource ID for the Application Insights resource')
118+
// workspaceResourceId: string
119+
@description('Retention period in days for the Application Insights resource')
120+
retentionInDays: app_insights_retention_in_days
121+
@description('Kind of the Application Insights resource')
122+
kind: app_insights_kind
123+
@description('Disable IP masking for the Application Insights resource')
124+
disableIpMasking: bool
125+
@description('Flow type for the Application Insights resource')
126+
flowType: app_insights_flow_type
127+
@description('Application Type for the Application Insights resource')
128+
applicationType: app_insights_applicationType
129+
@description('Disable local authentication for the Application Insights resource')
130+
disableLocalAuth: bool
131+
@description('Force customer storage for profiler in Application Insights resource')
132+
forceCustomerStorageForProfiler: bool
133+
@description('Public network access for ingestion in Application Insights resource')
134+
publicNetworkAccessForIngestion: 'Enabled' | 'Disabled'
135+
@description('Public network access for query in Application Insights resource')
136+
publicNetworkAccessForQuery: 'Enabled' | 'Disabled'
137+
@description('Request source for the Application Insights resource')
138+
requestSource: 'rest' | 'other'
139+
140+
@description('Name of the Log Analytics Workspace resource')
141+
logAnalyticsWorkspaceName: string
142+
@description('SKU name for the Log Analytics Workspace resource')
143+
skuName: app_insights_sku_name
144+
@description('This is the features properties for Log Analytics Workspace resource')
145+
features: {
146+
@description('Search version for the Log Analytics Workspace resource')
147+
searchVersion: 1
148+
}
149+
150+
151+
}

0 commit comments

Comments
 (0)