forked from ezYakaEagle442/aca-java-petclinic-mic-srv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acaPublicEnv.bicep
94 lines (80 loc) · 3.5 KB
/
acaPublicEnv.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@maxLength(20)
// to get a unique name each time ==> param appName string = 'demo${uniqueString(resourceGroup().id, deployment().name)}'
param appName string = 'petcliaca${uniqueString(resourceGroup().id)}'
param location string = 'westeurope'
@description('The Azure Container App Environment name')
param azureContainerAppEnvName string = 'aca-env-${appName}'
@description('The Log Analytics workspace name used by Azure Container App instance')
param logAnalyticsWorkspaceName string = 'log-${appName}'
param appInsightsName string = 'appi-${appName}'
param zoneRedundant bool = false
@allowed([
'log-analytics'
'azure-monitor'
])
@description('Cluster configuration which enables the log daemon to export app logs to a destination. Currently only "log-analytics" is supported https://learn.microsoft.com/en-us/azure/templates/microsoft.app/managedenvironments?pivots=deployment-language-bicep#managedenvironmentproperties')
param logDestination string = 'log-analytics' // 'log-analytics' or 'azure-monitor'
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' existing = {
name: logAnalyticsWorkspaceName
}
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' existing = {
name: appInsightsName
}
/*
ACA does not yet support diagnostic settings
container apps do no support currently diagnostic settings. Integration happen trough property on the app environment resource currently.
https://github.com/microsoft/azure-container-apps/issues/382
https://docs.microsoft.com/en-us/azure/templates/microsoft.insights/diagnosticsettings?tabs=bicep
*/
resource corpManagedEnvironment 'Microsoft.App/managedEnvironments@2022-06-01-preview' = {
name: azureContainerAppEnvName
location: location
properties: {
appLogsConfiguration: {
destination: logDestination // azure-monitor
logAnalyticsConfiguration: {
customerId: logAnalyticsWorkspace.properties.customerId
sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey
}
}
zoneRedundant: zoneRedundant
daprAIInstrumentationKey: appInsights.properties.InstrumentationKey
daprAIConnectionString: appInsights.properties.ConnectionString
}
}
output corpManagedEnvironmentId string = corpManagedEnvironment.id
output corpManagedEnvironmentDefaultDomain string = corpManagedEnvironment.properties.defaultDomain
output corpManagedEnvironmentStaticIp string = corpManagedEnvironment.properties.staticIp
// https://github.com/microsoft/azure-container-apps/issues/382#issuecomment-1278623205
// https://github.com/cwe1ss/msa-template/blob/db6f134dddf78f682b2cebd681fe11ebfb68026e/infrastructure/environment/app-environment.bicep
// https://github.com/microsoft/azure-container-apps/issues/382
/*
resource appInsightsDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: 'dgs-${appName}-send-${azureContainerAppEnvName}-logs-and-metrics-to-log-analytics'
scope: corpManagedEnvironment
properties: {
logAnalyticsDestinationType: 'AzureDiagnostics'
workspaceId: logAnalyticsWorkspace.id
logs: [
{
category: 'ContainerAppConsoleLogs'
enabled: true
}
{
category: 'ContainerAppSystemLogs'
enabled: true
}
]
metrics: [
{
category: 'AllMetrics'
enabled: true
retentionPolicy: {
days: 7
enabled: true
}
}
]
}
}
*/