Skip to content

Commit f146fab

Browse files
authored
Merge pull request #148 from microsoft/feature-avm-bk
refactor: avm changes for log analytics and app insights
2 parents 282b9b3 + dcc46a6 commit f146fab

5 files changed

Lines changed: 160 additions & 42 deletions

File tree

infra/main.bicep

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ module avmRoleAssignment 'br/public:avm/ptn/authorization/resource-role-assignme
141141
module avmKeyVault './modules/key-vault.bicep' = {
142142
name: format(deployment_param.resource_name_format_string, abbrs.security.keyVault)
143143
params: {
144-
name: format(deployment_param.resource_name_format_string, abbrs.security.keyVault)
144+
deployment_param: deployment_param
145145
keyVaultParams: {
146-
keyvault_name: '${abbrs.security.keyVault}${deployment_param.solution_prefix}'
146+
keyvaultName: '${abbrs.security.keyVault}${deployment_param.solution_prefix}'
147147
location: deployment_param.resource_group_location
148148
tags: {
149149
app: deployment_param.solution_prefix
@@ -182,41 +182,37 @@ module avmKeyVault './modules/key-vault.bicep' = {
182182
// scope: resourceGroup(resourceGroup().name)
183183
// }
184184

185-
// ========== Application insights ========== //
186-
module avmLogAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0.11.2' = {
187-
name: format(deployment_param.resource_name_format_string, abbrs.managementGovernance.logAnalyticsWorkspace)
188-
params: {
189-
name: '${abbrs.managementGovernance.logAnalyticsWorkspace}${deployment_param.solution_prefix}'
190-
location: deployment_param.resource_group_location
191-
diagnosticSettings: [{ useThisWorkspace: true }]
192-
skuName: 'PerGB2018'
193-
dataRetention: 30
194-
}
195-
}
196-
197-
module avmApplicationInsights 'br/public:avm/res/insights/component:0.6.0' = {
198-
name: format(deployment_param.resource_name_format_string, abbrs.managementGovernance.applicationInsights)
185+
// ========== Application insights and Log Analytics Workspace (AVM module) ========== //
186+
module avmAppInsightsAndLogAnalytics './modules/app-insights.bicep' = {
187+
name: format(deployment_param.resource_name_format_string, 'ai-law-avm')
199188
params: {
200-
name: '${abbrs.managementGovernance.applicationInsights}${deployment_param.solution_prefix}'
201-
location: deployment_param.resource_group_location
202-
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
203-
retentionInDays: 30
204-
kind: 'web'
205-
disableIpMasking: false
206-
flowType: 'Bluefield'
207-
diagnosticSettings: [{ workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId }]
189+
deployment_param: deployment_param
190+
appInsights_param: {
191+
appInsightsName: '${abbrs.managementGovernance.applicationInsights}${deployment_param.solution_prefix}'
192+
logAnalyticsWorkspaceName: '${abbrs.managementGovernance.logAnalyticsWorkspace}${deployment_param.solution_prefix}'
193+
location: deployment_param.resource_group_location
194+
kind: 'web'
195+
retentionInDays: 30
196+
features: {
197+
searchVersion: 1
198+
}
199+
skuName: 'PerGB2018'
200+
applicationType: 'web'
201+
disableIpMasking: false
202+
disableLocalAuth: false
203+
flowType: 'Bluefield'
204+
forceCustomerStorageForProfiler: false
205+
//ImmediatePurgeDataOn30Days: true
206+
//IngestionMode: 'LogAnalytics'
207+
publicNetworkAccessForIngestion: 'Enabled'
208+
publicNetworkAccessForQuery: 'Disabled'
209+
requestSource: 'rest'
210+
211+
}
208212
}
213+
scope: resourceGroup(resourceGroup().name)
209214
}
210215

211-
// module applicationInsights 'deploy_app_insights.bicep' = {
212-
// name: 'deploy_app_insights'
213-
// params: {
214-
// applicationInsightsName: '${abbrs.managementGovernance.applicationInsights}${solutionPrefix}'
215-
// logAnalyticsWorkspaceName: '${abbrs.managementGovernance.logAnalyticsWorkspace}${solutionPrefix}'
216-
// }
217-
// }
218-
219-
// // ========== Container Registry ========== //
220216
module avmContainerRegistry 'br/public:avm/res/container-registry/registry:0.9.1' = {
221217
name: format(deployment_param.resource_name_format_string, abbrs.containers.containerRegistry)
222218
params: {
@@ -375,7 +371,7 @@ module avmAiServices_storage_hub 'br/public:avm/res/storage/storage-account:0.20
375371
allowSharedKeyAccess: false
376372
diagnosticSettings: [
377373
{
378-
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
374+
workspaceResourceId: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceId
379375
}
380376
]
381377
blobServices: {
@@ -384,7 +380,7 @@ module avmAiServices_storage_hub 'br/public:avm/res/storage/storage-account:0.20
384380
containerDeleteRetentionPoloicyEnabled: false
385381
diagnosticSettings: [
386382
{
387-
workspaceResourceId: avmLogAnalyticsWorkspace.outputs.resourceId
383+
workspaceResourceId: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceId
388384
}
389385
]
390386
}
@@ -416,7 +412,7 @@ module avmAiHub 'br/public:avm/res/machine-learning-services/workspace:0.12.1' =
416412
associatedKeyVaultResourceId: avmKeyVault.outputs.resourceId
417413
associatedStorageAccountResourceId: avmAiServices_storage_hub.outputs.resourceId
418414
associatedContainerRegistryResourceId: avmContainerRegistry.outputs.resourceId
419-
associatedApplicationInsightsResourceId: avmApplicationInsights.outputs.resourceId
415+
associatedApplicationInsightsResourceId: avmAppInsightsAndLogAnalytics.outputs.applicationInsightsId
420416

421417
kind: 'Hub'
422418
connections: [
@@ -470,6 +466,18 @@ module avmAiProject 'br/public:avm/res/machine-learning-services/workspace:0.12.
470466
// scope: resourceGroup(resourceGroup().name)
471467
// }
472468

469+
//TODO: Remove
470+
471+
module avmLogAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0.11.2' = {
472+
name: 'workspaceDeployment'
473+
params: {
474+
// Required parameters
475+
name: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceName
476+
}
477+
scope: resourceGroup(resourceGroup().name)
478+
}
479+
480+
473481
// ========== Container App Environment ========== //
474482
module avmContainerAppEnv 'br/public:avm/res/app/managed-environment:0.11.1' = {
475483
name: format(deployment_param.resource_name_format_string, abbrs.containers.containerAppsEnvironment)
@@ -484,7 +492,7 @@ module avmContainerAppEnv 'br/public:avm/res/app/managed-environment:0.11.1' = {
484492
appLogsConfiguration: {
485493
destination: 'log-analytics'
486494
logAnalyticsConfiguration: {
487-
customerId: avmLogAnalyticsWorkspace.outputs.logAnalyticsWorkspaceId
495+
customerId: avmAppInsightsAndLogAnalytics.outputs.logAnalyticsWorkspaceId
488496
sharedKey: avmLogAnalyticsWorkspace.outputs.primarySharedKey
489497
}
490498
}

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/key-vault.bicep

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ metadata name = 'Key Vault Module'
1717

1818
import {
1919
key_vault_param_type
20+
default_deployment_param_type
2021
} from './types.bicep'
2122

2223
param keyVaultParams key_vault_param_type
23-
param name string
24-
24+
param deployment_param default_deployment_param_type
2525
module avmKeyVault 'br/public:avm/res/key-vault/vault:0.12.1' = {
26-
name: name
26+
name: 'deploy_keyvault'
2727
params: {
28-
name: keyVaultParams.name
28+
name: keyVaultParams.keyvaultName
2929
location: keyVaultParams.location
3030
tags: keyVaultParams.tags
3131
roleAssignments: keyVaultParams.roleAssignments
@@ -42,5 +42,7 @@ module avmKeyVault 'br/public:avm/res/key-vault/vault:0.12.1' = {
4242
}
4343
}
4444

45+
// Adding additional resource deployment for WAF enabled
46+
4547
output resourceId string = avmKeyVault.outputs.resourceId
4648
output vaultUri string = avmKeyVault.outputs.uri

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: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type keyvault_public_network_access_type = 'Disabled' | 'Enabled'
7272
@export()
7373
type key_vault_param_type = {
7474
@description('Name of the Key Vault')
75-
keyvault_name: string
75+
keyvaultName: string
7676
@description('Location of the Key Vault')
7777
location: string
7878
@description('Tags for the Key Vault')
@@ -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)