|
| 1 | +@description('Specifies the name of the container app.') |
| 2 | +param containerAppName string = 'app-${uniqueString(resourceGroup().id)}' |
| 3 | + |
| 4 | +@description('Specifies the name of the container app environment.') |
| 5 | +param containerAppEnvName string = 'env-${uniqueString(resourceGroup().id)}' |
| 6 | + |
| 7 | +@description('Specifies the name of the log analytics workspace.') |
| 8 | +param containerAppLogAnalyticsName string = 'log-${uniqueString(resourceGroup().id)}' |
| 9 | + |
| 10 | +@description('Specifies the location for all resources.') |
| 11 | +param location string = resourceGroup().location |
| 12 | + |
| 13 | +@description('Specifies the docker container image to deploy.') |
| 14 | +param containerImage string = 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' |
| 15 | + |
| 16 | +@description('Specifies the container port.') |
| 17 | +param targetPort int = 80 |
| 18 | + |
| 19 | +@description('Number of CPU cores the container can use. Can be with a maximum of two decimals.') |
| 20 | +@allowed([ |
| 21 | + '0.25' |
| 22 | + '0.5' |
| 23 | + '0.75' |
| 24 | + '1' |
| 25 | + '1.25' |
| 26 | + '1.5' |
| 27 | + '1.75' |
| 28 | + '2' |
| 29 | +]) |
| 30 | +param cpuCore string = '0.5' |
| 31 | + |
| 32 | +@description('Amount of memory (in gibibytes, GiB) allocated to the container up to 4GiB. Can be with a maximum of two decimals. Ratio with CPU cores must be equal to 2.') |
| 33 | +@allowed([ |
| 34 | + '0.5' |
| 35 | + '1' |
| 36 | + '1.5' |
| 37 | + '2' |
| 38 | + '3' |
| 39 | + '3.5' |
| 40 | + '4' |
| 41 | +]) |
| 42 | +param memorySize string = '1' |
| 43 | + |
| 44 | +@description('Minimum number of replicas that will be deployed') |
| 45 | +@minValue(0) |
| 46 | +@maxValue(25) |
| 47 | +param minReplicas int = 1 |
| 48 | + |
| 49 | +@description('Maximum number of replicas that will be deployed') |
| 50 | +@minValue(0) |
| 51 | +@maxValue(25) |
| 52 | +param maxReplicas int = 3 |
| 53 | + |
| 54 | +resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' = { |
| 55 | + name: containerAppLogAnalyticsName |
| 56 | + location: location |
| 57 | + properties: { |
| 58 | + sku: { |
| 59 | + name: 'PerGB2018' |
| 60 | + } |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +resource containerAppEnv 'Microsoft.App/managedEnvironments@2022-06-01-preview' = { |
| 65 | + name: containerAppEnvName |
| 66 | + location: location |
| 67 | + sku: { |
| 68 | + name: 'Consumption' |
| 69 | + } |
| 70 | + properties: { |
| 71 | + appLogsConfiguration: { |
| 72 | + destination: 'log-analytics' |
| 73 | + logAnalyticsConfiguration: { |
| 74 | + customerId: logAnalytics.properties.customerId |
| 75 | + sharedKey: logAnalytics.listKeys().primarySharedKey |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +resource containerApp 'Microsoft.App/containerApps@2022-06-01-preview' = { |
| 82 | + name: containerAppName |
| 83 | + location: location |
| 84 | + properties: { |
| 85 | + managedEnvironmentId: containerAppEnv.id |
| 86 | + configuration: { |
| 87 | + ingress: { |
| 88 | + external: true |
| 89 | + targetPort: targetPort |
| 90 | + allowInsecure: false |
| 91 | + traffic: [ |
| 92 | + { |
| 93 | + latestRevision: true |
| 94 | + weight: 100 |
| 95 | + } |
| 96 | + ] |
| 97 | + } |
| 98 | + } |
| 99 | + template: { |
| 100 | + revisionSuffix: 'firstrevision' |
| 101 | + containers: [ |
| 102 | + { |
| 103 | + name: containerAppName |
| 104 | + image: containerImage |
| 105 | + resources: { |
| 106 | + cpu: json(cpuCore) |
| 107 | + memory: '${memorySize}Gi' |
| 108 | + } |
| 109 | + } |
| 110 | + ] |
| 111 | + scale: { |
| 112 | + minReplicas: minReplicas |
| 113 | + maxReplicas: maxReplicas |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | +} |
| 118 | + |
| 119 | +output containerAppFQDN string = containerApp.properties.configuration.ingress.fqdn |
0 commit comments