Skip to content

Commit

Permalink
feat: add first batch of code to revision mgmt demo, minor updates to…
Browse files Browse the repository at this point in the history
… aca-store

Signed-off-by: Kristina Devochko <guidemetothemoon@gmail.com>
  • Loading branch information
guidemetothemoon committed Mar 31, 2024
1 parent 0df21e3 commit 39c69e5
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 15 deletions.
48 changes: 48 additions & 0 deletions aca-revision-and-traffic-management/main.bicep
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
// TODO
targetScope='subscription'

param acaResourceGroupName string
param environment string
param location string
param locationPrefix string
param tags object

resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: acaResourceGroupName
location: location
}

module common 'modules/common.bicep' = {
name: 'common'
scope: rg
params: {
environment: environment
location: location
tags: tags
}
}

module acaenvironment 'modules/aca-environment.bicep' = {
name: 'aca-environment'
scope: rg
params: {
location: location
managedIdentityId: common.outputs.managedIdentityId
tags: tags
}
dependsOn: [common]
}

module aca 'modules/aca.bicep' = {
name: 'aca'
scope: rg
params: {
environmentId: acaenvironment.outputs.environmentId
location: location
managedIdentityId: common.outputs.managedIdentityId
tags: tags
}
dependsOn: [acaenvironment]
}

@description('URL for store application')
output storeUrl string = aca.outputs.helloWorldAppUri
19 changes: 19 additions & 0 deletions aca-revision-and-traffic-management/modules/aca-environment.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
param location string
param managedIdentityId string
param tags object

resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-preview' = {
name: 'cae-aca-store'
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentityId}' : {}
}
}
tags: tags
}


output defaultDomain string = containerAppsEnvironment.properties.defaultDomain
output environmentId string = containerAppsEnvironment.id
72 changes: 72 additions & 0 deletions aca-revision-and-traffic-management/modules/aca.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
param environmentId string
param location string
param managedIdentityId string
param tags object

resource helloworld 'Microsoft.App/containerApps@2023-05-02-preview' = {
name: 'aca-helloworld'
location: location
tags: tags
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentityId}' : {}
}
}
properties: {
managedEnvironmentId: environmentId
configuration: {
ingress: {
external: true
targetPort: 80
transport: 'http'
clientCertificateMode: 'accept'
}
}
template: {
containers: [
{
image: 'mcr.microsoft.com/azuredocs/aks-helloworld:v1'
name: 'aca-helloworld'
resources: {
cpu: json('0.5')
memory: '1.0Gi'
}
env: [
{
name: 'TITLE'
value: 'Hello World from Azure Container Apps (ACA)!'
}
]
probes: [
{
type: 'Liveness'
httpGet: {
path: '/'
port: 80
}
initialDelaySeconds: 3
periodSeconds: 3
failureThreshold: 5
}
{
type: 'Readiness'
httpGet: {
path: '/'
port: 80
}
initialDelaySeconds: 3
periodSeconds: 3
failureThreshold: 3
}
]
}
]
scale: {
minReplicas: 1
}
}
}
}

output helloWorldAppUri string = 'https://${helloworld.properties.configuration.ingress.fqdn}'
12 changes: 12 additions & 0 deletions aca-revision-and-traffic-management/modules/common.bicep
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
// TODO
param environment string
param location string
param tags object

resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = {
name: 'uaid-aca-helloworld-common-${environment}'
location: location
tags: tags
}

output managedIdentityId string = managedIdentity.id
output managedIdentityName string = managedIdentity.name
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using '../main.bicep'

param acaResourceGroupName = 'rg-aca-helloworld-revision-${locationPrefix}-${environment}'
param acaResourceGroupName = 'rg-aca-helloworld-${locationPrefix}-${environment}'
param environment = 'dev'
param location = 'northeurope'
param locationPrefix = 'neu'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using '../main.bicep'

param acaResourceGroupName = 'rg-aca-aci-${locationPrefix}-${environment}'
param acaResourceGroupName = 'rg-aca-helloworld-${locationPrefix}-${environment}'
param environment = 'prod'
param location = 'northeurope'
param locationPrefix = 'neu'

param tags = {
application: 'aca-win-aci'
application: 'aca-revision-traffic-mgmt'
environment: environment
}
2 changes: 1 addition & 1 deletion aks-store-on-aca/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module acacommon 'modules/aca-common.bicep' = {
location: location
logAnalyticsCustomerId: azuremonitor.outputs.logAnalyticsCustomerId
logAnalyticsKey: keyVaultACAShared.getSecret(azuremonitor.outputs.logAnalyticsKey)
managedIdentityId: common.outputs.managedIdentityId
nsgName: vnet.outputs.nsgName
subnetId: vnet.outputs.acaSubnetId
tags: tags
Expand All @@ -132,7 +133,6 @@ module frontend 'modules/aca-public-apps.bicep' = {
name: 'frontend'
scope: rg
params: {
//defaultDomain: acacommon.outputs.defaultDomain
environmentId: acacommon.outputs.environmentId
location: location
makelineServiceUri: backend.outputs.makelineServiceUri
Expand Down
8 changes: 7 additions & 1 deletion aks-store-on-aca/modules/aca-common.bicep
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
param location string
param logAnalyticsCustomerId string
param managedIdentityId string
param nsgName string
param subnetId string
param tags object
Expand All @@ -15,6 +16,12 @@ param logAnalyticsKey string
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-preview' = {
name: 'cae-aca-store'
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentityId}' : {}
}
}
properties: {
appInsightsConfiguration: {
connectionString: appInsightsConnectionString
Expand Down Expand Up @@ -48,5 +55,4 @@ resource containerAppsInboundNsgRule 'Microsoft.Network/networkSecurityGroups/se
}
}

output defaultDomain string = containerAppsEnvironment.properties.defaultDomain
output environmentId string = containerAppsEnvironment.id
9 changes: 1 addition & 8 deletions aks-store-on-aca/modules/aca-public-apps.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,12 @@ resource storefront 'Microsoft.App/containerApps@2023-05-02-preview' = {
secretRef: 'nginx-conf'
path: 'default.conf'
}
{
secretRef: 'nginx-conf'
path: 'nginx.conf.template'
}
]
}
]
}
}
tags: tags
}

resource storeadmin 'Microsoft.App/containerApps@2023-05-02-preview' = {
Expand Down Expand Up @@ -236,10 +233,6 @@ resource storeadmin 'Microsoft.App/containerApps@2023-05-02-preview' = {
secretRef: 'nginx-conf'
path: 'default.conf'
}
{
secretRef: 'nginx-conf'
path: 'nginx.conf.template'
}
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions aks-store-on-aca/modules/keyvault.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-
}

resource keyVault 'Microsoft.KeyVault/vaults@2021-10-01' = {
name: 'kv-${uniqueString('keyvault', resourceGroup().id)}'
name: 'kv-${uniqueString('keyvault', resourceGroup().id, deployment().name)}'
location: location
properties: {
enabledForTemplateDeployment: true
enablePurgeProtection: false // for production you would want it to be enabled, i.e. set to 'true'
enableSoftDelete: false // for production you would want it to be enabled, i.e. set to 'true', together with purge protection (enablePurgeProtection: true)
enableRbacAuthorization: true
publicNetworkAccess: 'Disabled'
tenantId: tenantId
Expand Down

0 comments on commit 39c69e5

Please sign in to comment.