param image string = 'ghcr.io/gbaeke/super:1.0.5'
resource la 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
name: 'la-aca'
location: resourceGroup().location
properties: {
retentionInDays: 30
sku: {
name: 'PerGB2018'
}
}
}
resource env 'Microsoft.Web/kubeEnvironments@2021-02-01' = {
name: 'myenv'
location: resourceGroup().location
properties: {
// not recognized but type is required
type: 'managed'
internalLoadBalancerEnabled:false
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: la.properties.customerId
sharedKey: la.listKeys().primarySharedKey
}
}
}
}
resource frontContainerApp 'Microsoft.Web/containerApps@2021-03-01' = {
name: 'front'
location: resourceGroup().location
kind: 'containerapp'
properties: {
kubeEnvironmentId: env.id
configuration: {
ingress: {
external: true
targetPort: 8080
}
}
template: {
containers: [
{
image: image
name: 'super'
env: [
{
name: 'WELCOME'
value: 'Welcome to Container Apps'
}
]
}
]
scale: {
minReplicas: 0
maxReplicas: 10
rules: [
{
name: 'http-rule'
http: {
metadata: {
concurrentRequests: '5'
}
}
}
]
}
}
}
}
To deploy the above to a resource group rg-aca
, run:
az group create -n rg-aca -l northeurope
az deployment group create -n aca-deploy \
-g rg-aca \
--template-file ./main.bicep
The above template deploys the front
container app. If it is the first deployment, you automatically get a revision. The name of the revision is front--SOMETHINGRANDOM
.
You can control the revision suffix from Bicep (or ARM) with revisionSuffix
in the template section. In Bicep:
template: {
revisionSuffix: 'rev2'
containers: [...]
The above would result in revision name front--rev2
.
To control traffic to revisions, use the traffic
section in configuration
. With front--rev1
deployed, we can deploy a new version and configure a traffic split with 80% to rev1 and 20% to the latest revision like so:
configuration: {
activeRevisionsMode: 'multiple'
ingress: {
external: true
targetPort: 8080
traffic: [
{
revisionName: 'front--rev1'
weight: 80
}
{
latestRevision: true
weight: 20
}
]
}
}