forked from dotnet-architecture/eShopOnWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Azdev-ify changes for latest /bicep/core
- Loading branch information
zedy
committed
Nov 18, 2022
1 parent
c783174
commit 88a2778
Showing
45 changed files
with
762 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,5 +257,6 @@ pub/ | |
|
||
#Ignore marker-file used to know which docker files we have. | ||
.eshopdocker_* | ||
.devcontainer | ||
|
||
.azure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param databaseName string = 'CatalogDB' | ||
param keyVaultName string | ||
|
||
@secure() | ||
param sqlAdminPassword string | ||
@secure() | ||
param appUserPassword string | ||
|
||
// Because databaseName is optional in main.bicep, we make sure the database name is set here. | ||
var defaultDatabaseName = 'Todo' | ||
var actualDatabaseName = !empty(databaseName) ? databaseName : defaultDatabaseName | ||
|
||
module sqlServer1 '../core/database/sqlserver/sqlserver1.bicep' = { | ||
name: 'sqlServer01' | ||
params: { | ||
name: name | ||
location: location | ||
tags: tags | ||
databaseName: actualDatabaseName | ||
keyVaultName: keyVaultName | ||
sqlAdminPassword: sqlAdminPassword | ||
appUserPassword: appUserPassword | ||
} | ||
} | ||
|
||
output sqlCatalogConnectionStringKey string = sqlServer1.outputs.connectionStringKey | ||
output sqlCatalogDatabase1Name string = sqlServer1.outputs.databaseName |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param databaseName string = 'IdentityDB' | ||
param keyVaultName string | ||
|
||
@secure() | ||
param sqlAdminPassword string | ||
@secure() | ||
param appUserPassword string | ||
|
||
// Because databaseName is optional in main.bicep, we make sure the database name is set here. | ||
var defaultDatabaseName = 'Todo' | ||
var actualDatabaseName = !empty(databaseName) ? databaseName : defaultDatabaseName | ||
|
||
module sqlServer2 '../core/database/sqlserver/sqlserver2.bicep' = { | ||
name: 'sqlServer02' | ||
params: { | ||
name: name | ||
location: location | ||
tags: tags | ||
databaseName: actualDatabaseName | ||
keyVaultName: keyVaultName | ||
sqlAdminPassword: sqlAdminPassword | ||
appUserPassword: appUserPassword | ||
} | ||
} | ||
|
||
output sqlCatalogConnectionStringKey string = sqlServer2.outputs.connectionStringKey | ||
output sqlCatalogDatabase1Name string = sqlServer2.outputs.databaseName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
param environmentName string | ||
param name string | ||
param location string = resourceGroup().location | ||
param appServicePlanId string | ||
|
||
param tags object = {} | ||
param serviceName string = 'web' | ||
param appCommandLine string = 'pm2 serve /home/site/wwwroot --no-daemon --spa' | ||
param applicationInsightsName string = '' | ||
param appServicePlanId string | ||
param appSettings object = {} | ||
|
||
module web '../core/host/appservice-dotnet.bicep' = { | ||
name: '${serviceName}-appservice-dotnet-module' | ||
module web '../core/host/appservice.bicep' = { | ||
name: '${name}-deployment' | ||
params: { | ||
environmentName: environmentName | ||
name: name | ||
location: location | ||
appServicePlanId: appServicePlanId | ||
serviceName: serviceName | ||
runtimeName: 'dotnetcore' | ||
runtimeVersion: '6.0' | ||
tags: union(tags, { 'azd-service-name': serviceName }) | ||
scmDoBuildDuringDeployment: false | ||
} | ||
} | ||
|
||
output WEB_NAME string = web.outputs.name | ||
output WEB_URI string = web.outputs.uri | ||
output REACT_APP_WEB_BASE_URL string = web.outputs.uri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' | ||
param keyVaultName string | ||
|
||
@allowed([ 'GlobalDocumentDB', 'MongoDB', 'Parse' ]) | ||
param kind string | ||
|
||
resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = { | ||
name: name | ||
kind: kind | ||
location: location | ||
tags: tags | ||
properties: { | ||
consistencyPolicy: { defaultConsistencyLevel: 'Session' } | ||
locations: [ | ||
{ | ||
locationName: location | ||
failoverPriority: 0 | ||
isZoneRedundant: false | ||
} | ||
] | ||
databaseAccountOfferType: 'Standard' | ||
enableAutomaticFailover: false | ||
enableMultipleWriteLocations: false | ||
apiProperties: (kind == 'MongoDB') ? { serverVersion: '4.0' } : {} | ||
capabilities: [ { name: 'EnableServerless' } ] | ||
} | ||
} | ||
|
||
resource cosmosConnectionString 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { | ||
parent: keyVault | ||
name: connectionStringKey | ||
properties: { | ||
value: cosmos.listConnectionStrings().connectionStrings[0].connectionString | ||
} | ||
} | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | ||
name: keyVaultName | ||
} | ||
|
||
output connectionStringKey string = connectionStringKey | ||
output endpoint string = cosmos.properties.documentEndpoint | ||
output id string = cosmos.id | ||
output name string = cosmos.name |
22 changes: 22 additions & 0 deletions
22
infra/core/database/cosmos/mongo/cosmos-mongo-account.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param keyVaultName string | ||
param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' | ||
|
||
module cosmos '../../cosmos/cosmos-account.bicep' = { | ||
name: 'cosmos-account' | ||
params: { | ||
name: name | ||
location: location | ||
connectionStringKey: connectionStringKey | ||
keyVaultName: keyVaultName | ||
kind: 'MongoDB' | ||
tags: tags | ||
} | ||
} | ||
|
||
output connectionStringKey string = cosmos.outputs.connectionStringKey | ||
output endpoint string = cosmos.outputs.endpoint | ||
output id string = cosmos.outputs.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
param accountName string | ||
param databaseName string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param collections array = [] | ||
param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' | ||
param keyVaultName string | ||
|
||
module cosmos 'cosmos-mongo-account.bicep' = { | ||
name: 'cosmos-mongo-account' | ||
params: { | ||
name: accountName | ||
location: location | ||
keyVaultName: keyVaultName | ||
tags: tags | ||
connectionStringKey: connectionStringKey | ||
} | ||
} | ||
|
||
resource database 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases@2022-08-15' = { | ||
name: '${accountName}/${databaseName}' | ||
tags: tags | ||
properties: { | ||
resource: { id: databaseName } | ||
} | ||
|
||
resource list 'collections' = [for collection in collections: { | ||
name: collection.name | ||
properties: { | ||
resource: { | ||
id: collection.id | ||
shardKey: { _id: collection.shardKey } | ||
indexes: [ { key: { keys: [ collection.indexKey ] } } ] | ||
} | ||
} | ||
}] | ||
|
||
dependsOn: [ | ||
cosmos | ||
] | ||
} | ||
|
||
output connectionStringKey string = connectionStringKey | ||
output databaseName string = databaseName | ||
output endpoint string = cosmos.outputs.endpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param keyVaultName string | ||
|
||
module cosmos '../../cosmos/cosmos-account.bicep' = { | ||
name: 'cosmos-account' | ||
params: { | ||
name: name | ||
location: location | ||
tags: tags | ||
keyVaultName: keyVaultName | ||
kind: 'GlobalDocumentDB' | ||
} | ||
} | ||
|
||
output connectionStringKey string = cosmos.outputs.connectionStringKey | ||
output endpoint string = cosmos.outputs.endpoint | ||
output id string = cosmos.outputs.id | ||
output name string = cosmos.outputs.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
param accountName string | ||
param databaseName string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param containers array = [] | ||
param keyVaultName string | ||
param principalIds array = [] | ||
|
||
module cosmos 'cosmos-sql-account.bicep' = { | ||
name: 'cosmos-sql-account' | ||
params: { | ||
name: accountName | ||
location: location | ||
tags: tags | ||
keyVaultName: keyVaultName | ||
} | ||
} | ||
|
||
resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15' = { | ||
name: '${accountName}/${databaseName}' | ||
properties: { | ||
resource: { id: databaseName } | ||
} | ||
|
||
resource list 'containers' = [for container in containers: { | ||
name: container.name | ||
properties: { | ||
resource: { | ||
id: container.id | ||
partitionKey: { paths: [ container.partitionKey ] } | ||
} | ||
options: {} | ||
} | ||
}] | ||
|
||
dependsOn: [ | ||
cosmos | ||
] | ||
} | ||
|
||
module roleDefintion 'cosmos-sql-role-def.bicep' = { | ||
name: 'cosmos-sql-role-definition' | ||
params: { | ||
accountName: accountName | ||
} | ||
dependsOn: [ | ||
cosmos | ||
database | ||
] | ||
} | ||
|
||
// We need batchSize(1) here because sql role assignments have to be done sequentially | ||
@batchSize(1) | ||
module userRole 'cosmos-sql-role-assign.bicep' = [for principalId in principalIds: if (!empty(principalId)) { | ||
name: 'cosmos-sql-user-role-${uniqueString(principalId)}' | ||
params: { | ||
accountName: accountName | ||
roleDefinitionId: roleDefintion.outputs.id | ||
principalId: principalId | ||
} | ||
dependsOn: [ | ||
cosmos | ||
database | ||
] | ||
}] | ||
|
||
output accountId string = cosmos.outputs.id | ||
output accountName string = cosmos.outputs.name | ||
output connectionStringKey string = cosmos.outputs.connectionStringKey | ||
output databaseName string = databaseName | ||
output endpoint string = cosmos.outputs.endpoint | ||
output roleDefinitionId string = roleDefintion.outputs.id |
Oops, something went wrong.