File size: 2,206 Bytes
9595e1d |
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 |
param name string
param location string = resourceGroup().location
param tags object = {}
param containerAppsEnvironmentName string = ''
param containerName string = 'main'
param containerRegistryName string = ''
param env array = []
param external bool = true
param imageName string
param keyVaultName string = ''
param managedIdentity bool = !empty(keyVaultName)
param targetPort int = 80
@description('CPU cores allocated to a single container instance, e.g. 0.5')
param containerCpuCoreCount string = '0.5'
@description('Memory allocated to a single container instance, e.g. 1Gi')
param containerMemory string = '1.0Gi'
resource app 'Microsoft.App/containerApps@2022-03-01' = {
name: name
location: location
tags: tags
identity: { type: managedIdentity ? 'SystemAssigned' : 'None' }
properties: {
managedEnvironmentId: containerAppsEnvironment.id
configuration: {
activeRevisionsMode: 'single'
ingress: {
external: external
targetPort: targetPort
transport: 'auto'
}
secrets: [
{
name: 'registry-password'
value: containerRegistry.listCredentials().passwords[0].value
}
]
registries: [
{
server: '${containerRegistry.name}.azurecr.io'
username: containerRegistry.name
passwordSecretRef: 'registry-password'
}
]
}
template: {
containers: [
{
image: imageName
name: containerName
env: env
resources: {
cpu: json(containerCpuCoreCount)
memory: containerMemory
}
}
]
}
}
}
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' existing = {
name: containerAppsEnvironmentName
}
// 2022-02-01-preview needed for anonymousPullEnabled
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' existing = {
name: containerRegistryName
}
output identityPrincipalId string = managedIdentity ? app.identity.principalId : ''
output imageName string = imageName
output name string = app.name
output uri string = 'https://${app.properties.configuration.ingress.fqdn}'
|