Skip to content

Commit

Permalink
feat: show Azure Monitor log config in aca-revisions
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Devochko <[email protected]>
  • Loading branch information
guidemetothemoon committed Apr 2, 2024
1 parent 29edc4e commit 4fafe68
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions aca-revision-and-traffic-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This folder contains Bicep code for provisioning a demo application that can be
Implementation includes following modules:

* [common](modules/common.bicep): includes common, shared resources that are used by other resources in the deployment. For example, managed identities or deployment-specific Azure Policy assignments.
* [azure_monitor](modules/azure-monitor.bicep): includes observability-related resources, like Log Analytics, Application Insights, etc.
* [aca_common](modules/aca-common.bicep): includes resources that are common for Azure Container Apps, like Azure Container Apps environment.
* [public_apps](modules/aca-public-apps.bicep): includes container apps that are publicly accessible.

Expand Down
13 changes: 13 additions & 0 deletions aca-revision-and-traffic-management/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@ module common 'modules/common.bicep' = {
}
}

@description('Module that provisions Azure Monitor resources, like Log Analytics workspace and Application Insights.')
module azure_monitor 'modules/azure-monitor.bicep' = {
name: 'azure-monitor'
scope: rg
params: {
environment: environment
location: location
managedIdentityId: common.outputs.managedIdentityId
tags: tags
}
}

@description('Module that provisions common overall resources for Azure Container Apps, like Azure Container Apps environment.')
module aca_common 'modules/aca-common.bicep' = {
name: 'aca-common'
scope: rg
params: {
location: location
logAnalyticsWorkspaceId: azure_monitor.outputs.logAnalyticsWorkspaceId
managedIdentityId: common.outputs.managedIdentityId
tags: tags
}
Expand Down
27 changes: 25 additions & 2 deletions aca-revision-and-traffic-management/modules/aca-common.bicep
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
param location string
param logAnalyticsWorkspaceId string
param managedIdentityId string
param tags object

resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-preview' = {
name: 'cae-aca-store'
name: 'cae-aca-helloworld'
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentityId}' : {}
}
}
properties: { }
properties: {
appLogsConfiguration: {
/* In this demo Azure Monitor is configured as ACA logs destination: https://learn.microsoft.com/en-us/azure/container-apps/log-options
* If you would like to see how 'Log Analytics' option is configured, please check out ./aks-store-on-aca/modules/aca-common.bicep file
*/
destination: 'azure-monitor'
}
}
tags: tags
}

@description('Diagnostic setting for the ACA environment that\'s required when Azure Monitor is configured as logs destination.')
resource acaEnvironmentDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: containerAppsEnvironment.name
scope: containerAppsEnvironment
properties: {
workspaceId: logAnalyticsWorkspaceId
logs: [
{
categoryGroup: 'allLogs'
enabled: true
}
]
}
}


output defaultDomain string = containerAppsEnvironment.properties.defaultDomain
output environmentId string = containerAppsEnvironment.id
24 changes: 24 additions & 0 deletions aca-revision-and-traffic-management/modules/azure-monitor.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
param environment string
param location string
param managedIdentityId string
param tags object

resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
name: 'log-aca-helloworld-${environment}'
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentityId}' : {}
}
}
properties: {
retentionInDays: 30
sku: {
name: 'PerGB2018'
}
}
tags: tags
}

output logAnalyticsWorkspaceId string = logAnalytics.id
1 change: 1 addition & 0 deletions aks-store-on-aca/modules/aca-common.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-
vnetConfiguration: {
infrastructureSubnetId: subnetId
}
zoneRedundant: true
}
tags: tags
}
Expand Down

0 comments on commit 4fafe68

Please sign in to comment.