Skip to content

Commit c31afae

Browse files
author
Kendall Roden
committed
updates to make bicep more dyanmic
1 parent 0c0eb29 commit c31afae

File tree

8 files changed

+1185
-186
lines changed

8 files changed

+1185
-186
lines changed

.github/workflows/build.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
name: Build and Deploy
33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
# Publish semver tags as releases.
7-
tags: [ 'v*.*.*' ]
7+
tags: ["v*.*.*"]
88
workflow_dispatch:
99

1010
env:
@@ -16,7 +16,12 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
services: [ {'imageName': 'node-service', 'directory': './node-service'}, {'imageName': 'python-service', 'directory': './python-service'} , {'imageName': 'go-service', 'directory': './go-service'} ]
19+
services:
20+
[
21+
{ "imageName": "node-service", "directory": "./node-service" },
22+
{ "imageName": "python-service", "directory": "./python-service" },
23+
{ "imageName": "go-service", "directory": "./go-service" },
24+
]
2025
permissions:
2126
contents: read
2227
packages: write
@@ -51,7 +56,7 @@ jobs:
5156
type=semver,pattern={{major}}
5257
type=ref,event=branch
5358
type=sha
54-
59+
5560
# Build and push Docker image with Buildx (don't push on PR)
5661
# https://github.com/docker/build-push-action
5762
- name: Build and push Docker image
@@ -61,18 +66,18 @@ jobs:
6166
push: ${{ github.event_name != 'pull_request' }}
6267
tags: ${{ steps.meta.outputs.tags }}
6368
labels: ${{ steps.meta.outputs.labels }}
64-
69+
6570
- name: Output image tag
6671
id: image-tag
6772
run: echo "::set-output name=image-${{ matrix.services.imageName }}::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.services.imageName }}:sha-$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]'
68-
73+
6974
deploy:
7075
runs-on: ubuntu-latest
7176
needs: [build]
7277
steps:
7378
- name: Checkout repository
7479
uses: actions/checkout@v2
75-
80+
7681
- name: Azure Login
7782
uses: azure/login@v1
7883
with:
@@ -88,13 +93,11 @@ jobs:
8893
minReplicas=0 \
8994
nodeImage='${{ needs.build.outputs.containerImage-node }}' \
9095
nodePort=3000 \
91-
isNodeExternalIngress=true \
9296
pythonImage='${{ needs.build.outputs.containerImage-python }}' \
9397
pythonPort=5000 \
94-
isPythonExternalIngress=false \
9598
goImage='${{ needs.build.outputs.containerImage-go }}' \
9699
goPort=8050 \
97-
isGoExternalIngress=false \
98100
containerRegistry=${{ env.REGISTRY }} \
99101
containerRegistryUsername=${{ github.actor }} \
100-
containerRegistryPassword=${{ secrets.PACKAGES_TOKEN }}
102+
containerRegistryPassword=${{ secrets.PACKAGES_TOKEN }} \
103+
deployApim = true

README.md

Lines changed: 80 additions & 63 deletions
Large diffs are not rendered by default.

deploy/container-http.bicep

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,62 @@
11
param containerAppName string
2-
param location string = resourceGroup().location
3-
param environmentId string
2+
param location string
3+
param environmentName string
44
param containerImage string
55
param containerPort int
66
param isExternalIngress bool
77
param containerRegistry string
88
param containerRegistryUsername string
9-
param env array = []
9+
param isPrivateRegistry bool
10+
param enableIngress bool
11+
param registryPassword string
1012
param minReplicas int = 0
11-
param secrets array = [
12-
{
13-
name: 'docker-password'
14-
value: containerRegistryPassword
15-
}
16-
]
17-
18-
@allowed([
19-
'multiple'
20-
'single'
21-
])
22-
param revisionMode string = 'multiple'
13+
param secrets array = []
14+
param env array = []
2315

24-
@secure()
25-
param containerRegistryPassword string
2616

27-
var cpu = json('0.5')
28-
var memory = '500Mi'
29-
var registrySecretRefName = 'docker-password'
17+
resource environment 'Microsoft.App/managedEnvironments@2022-01-01-preview' existing = {
18+
name: environmentName
19+
}
3020

3121
resource containerApp 'Microsoft.App/containerApps@2022-01-01-preview' = {
3222
name: containerAppName
3323
location: location
3424
properties: {
35-
managedEnvironmentId: environmentId
25+
managedEnvironmentId: environment.id
3626
configuration: {
37-
// activeRevisionsMode: revisionMode
3827
secrets: secrets
39-
registries: [
28+
registries: isPrivateRegistry ? [
4029
{
4130
server: containerRegistry
4231
username: containerRegistryUsername
43-
passwordSecretRef: registrySecretRefName
32+
passwordSecretRef: registryPassword
4433
}
45-
]
46-
ingress: {
34+
] : null
35+
ingress: enableIngress ? {
4736
external: isExternalIngress
4837
targetPort: containerPort
4938
transport: 'auto'
50-
// traffic: [
51-
// {
52-
// weight: 100
53-
// latestRevision: true
54-
// }
55-
// ]
56-
}
39+
} : null
5740
dapr: {
5841
enabled: true
5942
appPort: containerPort
6043
appId: containerAppName
6144
}
6245
}
6346
template: {
64-
// revisionSuffix: 'somevalue'
6547
containers: [
6648
{
6749
image: containerImage
6850
name: containerAppName
6951
env: env
70-
// resources: {
71-
// cpu: cpu
72-
// memory: memory
73-
// }
7452
}
7553
]
7654
scale: {
7755
minReplicas: minReplicas
78-
// maxReplicas: 10
79-
// rules: [{
80-
// name: 'httpscale'
81-
// http: {
82-
// metadata: {
83-
// concurrentRequests: 100
84-
// }
85-
// }
86-
// }
87-
// ]
56+
maxReplicas: 1
8857
}
8958
}
9059
}
9160
}
9261

93-
output fqdn string = containerApp.properties.configuration.ingress.fqdn
62+
output fqdn string = enableIngress ? containerApp.properties.configuration.ingress.fqdn : 'Ingress not enabled'

deploy/cosmosdb.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
param accountName string = 'cosmos-${uniqueString(resourceGroup().id)}'
33

44
@description('Location for the Cosmos DB account.')
5-
param location string = resourceGroup().location
5+
param location string
66

77
@description('The primary replica region for the Cosmos DB account.')
8-
param primaryRegion string = resourceGroup().location
8+
param primaryRegion string
99

1010
@description('The default consistency level of the Cosmos DB account.')
1111
@allowed([

deploy/environment.bicep

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
param environmentName string
2-
param logAnalyticsWorkspaceName string = 'logs-${environmentName}'
3-
param appInsightsName string = 'appins-${environmentName}'
4-
param location string = resourceGroup().location
2+
param logAnalyticsWorkspaceName string
3+
param appInsightsName string
4+
param location string
55

66
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = {
77
name: logAnalyticsWorkspaceName
@@ -17,31 +17,32 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03
1717
})
1818
}
1919

20-
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
20+
21+
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
2122
name: appInsightsName
2223
location: location
2324
kind: 'web'
24-
properties: {
25+
properties: {
2526
Application_Type: 'web'
26-
Flow_Type: 'Redfield'
27-
Request_Source: 'CustomDeployment'
27+
WorkspaceResourceId:logAnalyticsWorkspace.id
2828
}
2929
}
3030

3131
resource environment 'Microsoft.App/managedEnvironments@2022-01-01-preview' = {
3232
name: environmentName
3333
location: location
3434
properties: {
35+
daprAIInstrumentationKey:appInsights.properties.InstrumentationKey
3536
appLogsConfiguration: {
3637
destination: 'log-analytics'
3738
logAnalyticsConfiguration: {
3839
customerId: logAnalyticsWorkspace.properties.customerId
3940
sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey
4041
}
4142
}
42-
daprAIInstrumentationKey: appInsights.properties.InstrumentationKey
4343
}
4444
}
4545

46+
4647
output location string = location
4748
output environmentId string = environment.id

0 commit comments

Comments
 (0)