This commit is contained in:
Chris Kruining 2024-11-28 07:18:53 +01:00
parent 76c5de5c32
commit 22c733d8da
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
7 changed files with 133 additions and 125 deletions

View file

@ -1,4 +1,6 @@
import { Context } from 'types.bicep' import { Context } from 'br/Tricep:types:latest'
import { with_name } from 'br/Tricep:common/context:latest'
import { container_app_environment, container_app, container, with_app_logs, with_auto_scaling, with_environment } from 'br/Tricep:recommended/app/container-app:latest'
targetScope = 'resourceGroup' targetScope = 'resourceGroup'
@ -6,96 +8,92 @@ param context Context
param version string param version string
@secure() @secure()
param registryUrl string param registryUrl string
param customerId string
param sharedKey string
var appName = 'app' var appName = 'app'
resource environment 'Microsoft.App/managedEnvironments@2024-03-01' = { var environmentConfig = container_app_environment(with_name(context, 'app'), [
name: 'cea-${context.locationAbbreviation}-${context.environment}-${context.projectName}' with_app_logs(customerId, sharedKey)
location: context.location {
properties: { properties: {
appLogsConfiguration: { appLogsConfiguration: {
destination: 'azure-monitor' destination: 'azure-monitor'
}
peerAuthentication: {
mtls: {
enabled: false
} }
} peerAuthentication: {
peerTrafficConfiguration: { mtls: {
encryption: { enabled: false
enabled: false }
}
peerTrafficConfiguration: {
encryption: {
enabled: false
}
} }
} }
} }
])
var appConfig = container_app(
with_name(context, 'app'),
[
container('${context.project}-${appName}', '${registryUrl}/${context.project}-${appName}:${version}')
],
[
with_environment(environment.id)
with_auto_scaling(0, 1, {
ruleName: {
concurrentRequests: '10'
}
})
{
properties: {
configuration: {
activeRevisionsMode: 'Single'
ingress: {
external: true
targetPort: 3000
transport: 'auto'
allowInsecure: false
traffic: [
{
weight: 100
latestRevision: true
}
]
corsPolicy: {
allowedOrigins: [
// 'https://localhost:3000'
'*'
]
allowCredentials: true
allowedHeaders: ['*']
allowedMethods: ['Get, POST']
maxAge: 0
}
}
registries: [
{
identity: 'system'
server: registryUrl
}
]
}
}
}
]
)
resource environment 'Microsoft.App/managedEnvironments@2024-03-01' = {
name: environmentConfig.name
location: environmentConfig.location
properties: environmentConfig.properties
} }
resource app 'Microsoft.App/containerApps@2024-03-01' = { resource app 'Microsoft.App/containerApps@2024-03-01' = {
name: 'ca-${context.locationAbbreviation}-${context.environment}-${context.projectName}-app' name: appConfig.name
location: context.location location: appConfig.location
identity: { identity: appConfig.identity
type: 'SystemAssigned' properties: appConfig.properties
}
properties: {
environmentId: environment.id
configuration: {
activeRevisionsMode: 'Single'
ingress: {
external: true
targetPort: 3000
transport: 'auto'
allowInsecure: false
traffic: [
{
weight: 100
latestRevision: true
}
]
corsPolicy: {
allowedOrigins: [
// 'https://localhost:3000'
'*'
]
allowCredentials: true
allowedHeaders: ['*']
allowedMethods: ['Get, POST']
maxAge: 0
}
}
registries: [
{
identity: 'system'
server: registryUrl
}
]
}
template: {
containers: [
{
image: '${registryUrl}/${context.projectName}-${appName}:${version}'
name: '${context.projectName}-${appName}'
resources: {
cpu: json('0.25')
memory: '0.5Gi'
}
}
]
scale: {
minReplicas: 1
maxReplicas: 2
rules: [
{
name: 'http-rule'
http: {
metadata: {
concurrentRequests: '50'
}
}
}
]
}
}
}
} }

View file

@ -7,5 +7,12 @@
"resourceTypedParamsAndOutputs": true, "resourceTypedParamsAndOutputs": true,
"sourceMapping": true, "sourceMapping": true,
"symbolicNameCodegen": true "symbolicNameCodegen": true
},
"moduleAliases": {
"br": {
"Tricep": {
"registry": "acreuwprdtricep.azurecr.io"
}
}
} }
} }

View file

@ -1,8 +1,8 @@
import { Context } from 'types.bicep' import { create_context } from 'br/Tricep:common/context:latest'
import { resource_group } from 'br/Tricep:recommended/resources/resource-group:latest'
targetScope = 'subscription' targetScope = 'subscription'
param locationAbbreviation string
param location string param location string
param environment string param environment string
param projectName string param projectName string
@ -11,17 +11,22 @@ param version string
param registryUrl string param registryUrl string
param deployedAt string = utcNow('yyyyMMdd') param deployedAt string = utcNow('yyyyMMdd')
var context = { var context = create_context({
locationAbbreviation: locationAbbreviation name: ''
project: projectName
nameConventionTemplate: '$type-$env-$loc-$project-$name'
location: location location: location
environment: environment environment: environment
projectName: projectName
deployedAt: deployedAt deployedAt: deployedAt
} tenant: tenant()
tags: {}
})
var resourceGroupConfig = resource_group(context, [])
resource calqueResourceGroup 'Microsoft.Resources/resourceGroups@2024-07-01' = { resource calqueResourceGroup 'Microsoft.Resources/resourceGroups@2024-07-01' = {
name: 'rg-${locationAbbreviation}-${environment}-${projectName}' name: resourceGroupConfig.name
location: location location: resourceGroupConfig.location
} }
module monitoring 'monitoring.bicep' = { module monitoring 'monitoring.bicep' = {

View file

@ -1,11 +1,17 @@
import { Context } from 'types.bicep' import { Context } from 'br/Tricep:types:latest'
import { with_managed_identity } from 'br/Tricep:common/identity:latest'
import { log_analytics } from 'br/Tricep:recommended/operational-insights/log-analytics:latest'
targetScope = 'resourceGroup' targetScope = 'resourceGroup'
param context Context param context Context
// resource monitoring 'Microsoft.___/___@___' = { var logAnalyticsConfig = log_analytics(context, [
// name: '___-${context.locationAbbreviation}-${context.environment}-${context.projectName}' with_managed_identity()
// location: context.location ])
// properties: {}
// } resource monitoring 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
name: logAnalyticsConfig.name
location: logAnalyticsConfig.location
properties: logAnalyticsConfig.properties
}

View file

@ -1,6 +1,5 @@
using '../main.bicep' using '../main.bicep'
param locationAbbreviation = 'euw'
param location = 'westeurope' param location = 'westeurope'
param environment = 'prd' param environment = 'prd'
param projectName = 'calque' param projectName = 'calque'

View file

@ -1,23 +1,28 @@
import { Context } from 'types.bicep' import { Context } from 'br/Tricep:types:latest'
import { with_managed_identity } from 'br/Tricep:common/identity:latest'
import { container_registry } from 'br/Tricep:recommended/container-registry/container-registry:latest'
targetScope = 'resourceGroup' targetScope = 'resourceGroup'
param context Context param context Context
resource registry 'Microsoft.ContainerRegistry/registries@2023-07-01' = { var registryConfig = container_registry(context, [
name: 'acr${context.locationAbbreviation}${context.environment}${context.projectName}' with_managed_identity()
location: context.location {
sku: { properties: {
name: 'Basic' adminUserEnabled: true
} dataEndpointEnabled: false
identity: { encryption: {
type: 'SystemAssigned' status: 'disabled'
} }
properties: {
adminUserEnabled: true
dataEndpointEnabled: false
encryption: {
status: 'disabled'
} }
} }
])
resource registry 'Microsoft.ContainerRegistry/registries@2023-07-01' = {
name: registryConfig.name
location: registryConfig.location
sku: registryConfig.sku
identity: registryConfig.identity
properties: registryConfig.properties
} }

View file

@ -1,12 +0,0 @@
@export()
type Context = {
@minLength(2)
locationAbbreviation: string
@minLength(2)
location: string
@minLength(3)
environment: string
@minLength(2)
projectName: string
deployedAt: string
}