Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tutorial/app.bicep
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//APPBASE
import radius as radius

param environment string
Expand All @@ -9,7 +10,9 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = {
environment: environment
}
}
//APPBASE

//CONTAINER
resource frontend 'Applications.Core/containers@2022-03-15-privatepreview' = {
name: 'frontend'
location: 'global'
Expand Down Expand Up @@ -39,7 +42,9 @@ resource frontendRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview'
application: app.id
}
}
//CONTAINER

//GATEWAY
resource gateway 'Applications.Core/gateways@2022-03-15-privatepreview' = {
name: 'public'
location: 'global'
Expand All @@ -53,22 +58,28 @@ resource gateway 'Applications.Core/gateways@2022-03-15-privatepreview' = {
]
}
}
//GATEWAY

//DATABASE LINK
resource db 'Applications.Link/mongoDatabases@2022-03-15-privatepreview' = {
name: 'db'
location: 'global'
properties: {
environment: app.properties.environment
application: app.id
mode: 'values'
host: mongo.outputs.name
host: mongo.outputs.host
port: mongo.outputs.port
secrets: {
connectionString: 'mongodb://${mongo.outputs.name}:${mongo.outputs.port}/${mongo.outputs.dbName}?authSource=admin'
// Manually build the link from the connectionString value
connectionString: mongo.outputs.connectionString
}
}
}
//DATABASE LINK

//MONGOMODULE
module mongo 'mongo-container.bicep' = {
name: 'mongo-module'
}
//MONGOMODULE
3 changes: 2 additions & 1 deletion tutorial/azure-cosmosdb.bicep
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import radius as radius

param location string

param name string = 'todoapp-cosmos-${uniqueString(resourceGroup().id)}'

//COSMOS
resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
name: toLower(name)
location: location
Expand Down Expand Up @@ -33,5 +33,6 @@ resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
}

}
//COSMOS

output cosmosDatabaseId string = cosmosAccount::cosmosDb.id
55 changes: 29 additions & 26 deletions tutorial/mongo-container.bicep
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//MONGO
import kubernetes as kubernetes {
kubeConfig: ''
namespace: namespace
Expand All @@ -8,6 +9,7 @@ param name string = 'mongo'

var port = 27017

//SS
resource statefulset 'apps/StatefulSet@v1' = {
metadata: {
name: name
Expand Down Expand Up @@ -97,6 +99,33 @@ resource statefulset 'apps/StatefulSet@v1' = {
]
}
}
//SS
//SERVICE
resource service 'core/Service@v1' = {
metadata: {
name: name
labels: {
app: name
}
}
spec: {
clusterIP: 'None'
ports: [
{
port: port
}
]
selector: {
app: name
}
}
}
//SERVICE

output host string = name
output port int = int(port)
output connectionString string = 'mongodb://${name}.${namespace}.svc.cluster.local:${port}/${name}?authSource=admin'
//MONGO

resource sa 'core/ServiceAccount@v1' = {
metadata: {
Expand Down Expand Up @@ -157,29 +186,3 @@ resource secret 'core/Secret@v1' = {
connectionString: 'mongodb://${name}.${namespace}.svc.cluster.local:${port}/${name}?authSource=admin'
}
}

resource service 'core/Service@v1' = {
metadata: {
name: name
labels: {
app: name
}
}
spec: {
clusterIP: 'None'
ports: [
{
port: port
}
]
selector: {
app: name
}
}
}

output name string = '${name}.${namespace}.svc.cluster.local'
output dbName string = name
output port int = port

output connectionString string = 'mongodb://${name}.${namespace}.svc.cluster.local:${port}/${name}?authSource=admin'