This commit is contained in:
Paul Yu 2023-02-04 22:57:13 -08:00 коммит произвёл GitHub
Родитель ef6392e716
Коммит 63be196780
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 403 добавлений и 774 удалений

Просмотреть файл

@ -0,0 +1,20 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {
"version": "latest",
"installBicep": "true"
},
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers/features/dotnet:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot",
"GitHub.copilot-labs",
"ms-azuretools.vscode-bicep"
]
}
}
}

5
.vscode/settings.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,5 @@
{
"dotnetAcquisitionExtension.existingDotnetPath": [
"/usr/local/dotnet/current/dotnet"
]
}

Просмотреть файл

@ -1,3 +1,5 @@
param location string = resourceGroup().location
@description('Name of azure web app')
param siteName string
@ -65,34 +67,23 @@ param skuName string = 'S1'
@minValue(1)
param skuCapacity int = 1
@description('Azure database for MySQL sku Size ')
param databaseSkuSizeMB int = 5120
@description('Initial MySQL database storage size in GB ')
param databaseStorageSizeGB int = 32
@description('Select MySql server performance tier. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region.')
@allowed([
'Basic'
'GeneralPurpose'
'MemoryOptimized'
])
param databaseForMySqlTier string = 'GeneralPurpose'
@description('Initial MySQL databse storage IOPS')
param databaseStorageIops int = 396
@description('Select MySql compute generation. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region.')
@allowed([
'Gen4'
'Gen5'
'Enabled'
'Disabled'
])
param databaseForMySqlFamily string = 'Gen5'
param databaseStorageAutoGrow string = 'Enabled'
@description('Select MySql vCore count. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region.')
@allowed([
1
2
4
8
16
32
'Enabled'
'Disabled'
])
param databaseForMySqlCores int = 2
param databseStorageAutoIoScaling string = 'Enabled'
@description('MySQL version')
@allowed([
@ -120,23 +111,17 @@ param repoURL string = 'https://github.com/microsoft/azure-redcap-paas.git'
@description('The main branch of the application repo')
param branch string = 'main'
var siteName_var = replace(siteName, ' ', '')
var databaseName = '${siteName_var}_db'
var serverName_var = '${siteName_var}${uniqueString(resourceGroup().id)}'
var hostingPlanName_var = '${siteName_var}_serviceplan'
var webSiteName_var = '${siteName_var}${uniqueString(resourceGroup().id)}'
var tierSymbol = {
Basic: 'B'
GeneralPurpose: 'GP'
MemoryOptimized: 'MO'
}
var databaseForMySqlSku = '${tierSymbol[databaseForMySqlTier]}_${databaseForMySqlFamily}_${databaseForMySqlCores}'
var storageName_var = 'storage${uniqueString(resourceGroup().id)}'
var storageAccountId = '${resourceGroup().id}/providers/Microsoft.Storage/storageAccounts/${storageName_var}'
var siteNameCleaned = replace(siteName, ' ', '')
var databaseName = '${siteNameCleaned}_db'
var uniqueServerName = '${siteNameCleaned}${uniqueString(resourceGroup().id)}'
var hostingPlanNameCleaned = '${siteNameCleaned}_serviceplan'
var uniqueWebSiteName = '${siteNameCleaned}${uniqueString(resourceGroup().id)}'
var uniqueStorageName = 'storage${uniqueString(resourceGroup().id)}'
var storageAccountId = '${resourceGroup().id}/providers/Microsoft.Storage/storageAccounts/${uniqueStorageName}'
resource storageName 'Microsoft.Storage/storageAccounts@2016-01-01' = {
name: storageName_var
location: resourceGroup().location
name: uniqueStorageName
location: location
sku: {
name: storageType
}
@ -158,8 +143,8 @@ resource storageContainer 'Microsoft.Storage/storageAccounts/blobServices/contai
}
resource hostingPlanName 'Microsoft.Web/serverfarms@2016-09-01' = {
name: hostingPlanName_var
location: resourceGroup().location
name: hostingPlanNameCleaned
location: location
tags: {
displayName: 'HostingPlan'
}
@ -169,30 +154,23 @@ resource hostingPlanName 'Microsoft.Web/serverfarms@2016-09-01' = {
}
kind: 'linux'
properties: {
name: hostingPlanName_var
name: hostingPlanNameCleaned
reserved: true
}
}
resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
name: webSiteName_var
location: resourceGroup().location
name: uniqueWebSiteName
location: location
tags: {
displayName: 'WebApp'
}
properties: {
name: webSiteName_var
serverFarmId: hostingPlanName_var
name: uniqueWebSiteName
serverFarmId: hostingPlanNameCleaned
siteConfig: {
linuxFxVersion: linuxFxVersion
alwaysOn: true
connectionStrings: [
{
name: 'defaultConnection'
connectionString: 'Database=${databaseName};Data Source=${serverName_var}.mysql.database.azure.com;User Id=${administratorLogin}@${serverName_var};Password=${administratorLoginPassword}'
type: 'MySql'
}
]
appCommandLine: '/home/startup.sh'
appSettings: [
{
@ -201,7 +179,7 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
}
{
name: 'StorageAccount'
value: storageName_var
value: uniqueStorageName
}
{
name: 'StorageKey'
@ -225,7 +203,7 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
}
{
name: 'DBHostName'
value: '${serverName_var}.mysql.database.azure.com'
value: '${uniqueServerName}.mysql.database.azure.com'
}
{
name: 'DBName'
@ -233,12 +211,16 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
}
{
name: 'DBUserName'
value: '${administratorLogin}@${serverName_var}'
value: administratorLogin
}
{
name: 'DBPassword'
value: administratorLoginPassword
}
{
name: 'DBSslCa'
value: '/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem'
}
{
name: 'PHP_INI_SCAN_DIR'
value: '/usr/local/etc/php/conf.d:/home/site'
@ -279,7 +261,7 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
resource webSiteName_web 'Microsoft.Web/sites/sourcecontrols@2015-08-01' = {
parent: webSiteName
name: 'web'
location: resourceGroup().location
location: location
tags: {
displayName: 'CodeDeploy'
}
@ -293,9 +275,9 @@ resource webSiteName_web 'Microsoft.Web/sites/sourcecontrols@2015-08-01' = {
]
}
resource serverName 'Microsoft.DBforMySQL/servers@2017-12-01-preview' = {
location: resourceGroup().location
name: serverName_var
resource serverName 'Microsoft.DBforMySQL/flexibleServers@2021-12-01-preview' = {
location: location
name: uniqueServerName
tags: {
displayName: 'MySQLAzure'
}
@ -303,21 +285,29 @@ resource serverName 'Microsoft.DBforMySQL/servers@2017-12-01-preview' = {
version: mysqlVersion
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
storageProfile: {
storageMB: databaseSkuSizeMB
backupRetentionDays: '7'
storage: {
storageSizeGB: databaseStorageSizeGB
iops: databaseStorageIops
autoGrow: databaseStorageAutoGrow
autoIoScaling: databseStorageAutoIoScaling
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
sslEnforcement: 'Disabled'
highAvailability: {
mode: 'Disabled'
}
replicationRole: 'None'
}
sku: {
name: databaseForMySqlSku
name: 'Standard_B1ms'
tier: 'Burstable'
}
}
resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/servers/firewallrules@2017-12-01-preview' = {
resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/flexibleServers/firewallRules@2021-12-01-preview' = {
parent: serverName
location: resourceGroup().location
name: 'AllowAzureIPs'
properties: {
startIpAddress: '0.0.0.0'
@ -328,21 +318,17 @@ resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/servers/firewallrules@20
]
}
resource serverName_databaseName 'Microsoft.DBforMySQL/servers/databases@2017-12-01' = {
resource serverName_databaseName 'Microsoft.DBforMySQL/flexibleServers/databases@2021-12-01-preview' = {
parent: serverName
name: '${databaseName}'
tags: {
displayName: 'DB'
}
name: databaseName
properties: {
charset: 'utf8'
collation: 'utf8_general_ci'
}
}
output MySQLHostName string = '${serverName_var}.mysql.database.azure.com'
output MySqlUserName string = '${administratorLogin}@${serverName_var}'
output webSiteFQDN string = '${webSiteName_var}.azurewebsites.net'
output storageAccountKey string = concat(listKeys(storageAccountId, '2015-05-01-preview').key1)
output storageAccountName string = storageName_var
output MySQLHostName string = '${uniqueServerName}.mysql.database.azure.com'
output MySqlUserName string = '${administratorLogin}@${uniqueServerName}'
output webSiteFQDN string = '${uniqueWebSiteName}.azurewebsites.net'
output storageAccountName string = uniqueStorageName
output storageContainerName string = storageContainerName

Просмотреть файл

@ -4,11 +4,15 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.7.4.23292",
"templateHash": "14039527216535323467"
"version": "0.14.6.61914",
"templateHash": "10457554200344794888"
}
},
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"siteName": {
"type": "string",
"metadata": {
@ -31,7 +35,7 @@
}
},
"administratorLoginPassword": {
"type": "secureString",
"type": "securestring",
"minLength": 8,
"metadata": {
"description": "Database administrator password"
@ -51,7 +55,7 @@
}
},
"redcapCommunityPassword": {
"type": "secureString",
"type": "securestring",
"metadata": {
"description": "REDCap Community site password for downloading the REDCap zip file."
}
@ -82,7 +86,7 @@
}
},
"smtpPassword": {
"type": "secureString",
"type": "securestring",
"metadata": {
"description": "Login password for your SMTP relay"
}
@ -125,51 +129,36 @@
"description": "Describes plan's instance count (how many distinct web servers will be deployed in the farm) - this can be changed after deployment"
}
},
"databaseSkuSizeMB": {
"databaseStorageSize": {
"type": "int",
"defaultValue": 5120,
"defaultValue": 32,
"metadata": {
"description": "Azure database for MySQL sku Size "
"description": "Initial MySQL database storage size "
}
},
"databaseForMySqlTier": {
"type": "string",
"defaultValue": "GeneralPurpose",
"allowedValues": [
"Basic",
"GeneralPurpose",
"MemoryOptimized"
],
"metadata": {
"description": "Select MySql server performance tier. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region."
}
},
"databaseForMySqlFamily": {
"type": "string",
"defaultValue": "Gen5",
"allowedValues": [
"Gen4",
"Gen5"
],
"metadata": {
"description": "Select MySql compute generation. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region."
}
},
"databaseForMySqlCores": {
"databaseStorageIops": {
"type": "int",
"defaultValue": 2,
"allowedValues": [
1,
2,
4,
8,
16,
32
],
"defaultValue": 396,
"metadata": {
"description": "Select MySql vCore count. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region."
"description": "Initial MySQL databse storage IOPS"
}
},
"databaseStorageAutoGrow": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [
"Enabled",
"Disabled"
]
},
"databseStorageAutoIoScaling": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [
"Enabled",
"Disabled"
]
},
"mysqlVersion": {
"type": "string",
"defaultValue": "5.7",
@ -218,26 +207,20 @@
}
},
"variables": {
"siteName_var": "[replace(parameters('siteName'), ' ', '')]",
"databaseName": "[format('{0}_db', variables('siteName_var'))]",
"serverName_var": "[format('{0}{1}', variables('siteName_var'), uniqueString(resourceGroup().id))]",
"hostingPlanName_var": "[format('{0}_serviceplan', variables('siteName_var'))]",
"webSiteName_var": "[format('{0}{1}', variables('siteName_var'), uniqueString(resourceGroup().id))]",
"tierSymbol": {
"Basic": "B",
"GeneralPurpose": "GP",
"MemoryOptimized": "MO"
},
"databaseForMySqlSku": "[format('{0}_{1}_{2}', variables('tierSymbol')[parameters('databaseForMySqlTier')], parameters('databaseForMySqlFamily'), parameters('databaseForMySqlCores'))]",
"storageName_var": "[format('storage{0}', uniqueString(resourceGroup().id))]",
"storageAccountId": "[format('{0}/providers/Microsoft.Storage/storageAccounts/{1}', resourceGroup().id, variables('storageName_var'))]"
"siteNameCleaned": "[replace(parameters('siteName'), ' ', '')]",
"databaseName": "[format('{0}_db', variables('siteNameCleaned'))]",
"uniqueServerName": "[format('{0}{1}', variables('siteNameCleaned'), uniqueString(resourceGroup().id))]",
"hostingPlanNameCleaned": "[format('{0}_serviceplan', variables('siteNameCleaned'))]",
"uniqueWebSiteName": "[format('{0}{1}', variables('siteNameCleaned'), uniqueString(resourceGroup().id))]",
"uniqueStorageName": "[format('storage{0}', uniqueString(resourceGroup().id))]",
"storageAccountId": "[format('{0}/providers/Microsoft.Storage/storageAccounts/{1}', resourceGroup().id, variables('uniqueStorageName'))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2016-01-01",
"name": "[variables('storageName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('uniqueStorageName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageType')]"
},
@ -249,24 +232,24 @@
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2021-09-01",
"name": "[format('{0}/{1}', variables('storageName_var'), 'default')]",
"name": "[format('{0}/{1}', variables('uniqueStorageName'), 'default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageName_var'))]"
"[resourceId('Microsoft.Storage/storageAccounts', variables('uniqueStorageName'))]"
]
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2021-09-01",
"name": "[format('{0}/{1}/{2}', variables('storageName_var'), 'default', parameters('storageContainerName'))]",
"name": "[format('{0}/{1}/{2}', variables('uniqueStorageName'), 'default', parameters('storageContainerName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('storageName_var'), 'default')]"
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('uniqueStorageName'), 'default')]"
]
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2016-09-01",
"name": "[variables('hostingPlanName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('hostingPlanNameCleaned')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "HostingPlan"
},
@ -276,31 +259,24 @@
},
"kind": "linux",
"properties": {
"name": "[variables('hostingPlanName_var')]",
"name": "[variables('hostingPlanNameCleaned')]",
"reserved": true
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"name": "[variables('webSiteName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('uniqueWebSiteName')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "WebApp"
},
"properties": {
"name": "[variables('webSiteName_var')]",
"serverFarmId": "[variables('hostingPlanName_var')]",
"name": "[variables('uniqueWebSiteName')]",
"serverFarmId": "[variables('hostingPlanNameCleaned')]",
"siteConfig": {
"linuxFxVersion": "[parameters('linuxFxVersion')]",
"alwaysOn": true,
"connectionStrings": [
{
"name": "defaultConnection",
"connectionString": "[format('Database={0};Data Source={1}.mysql.database.azure.com;User Id={2}@{3};Password={4}', variables('databaseName'), variables('serverName_var'), parameters('administratorLogin'), variables('serverName_var'), parameters('administratorLoginPassword'))]",
"type": "MySql"
}
],
"appCommandLine": "/home/startup.sh",
"appSettings": [
{
@ -309,7 +285,7 @@
},
{
"name": "StorageAccount",
"value": "[variables('storageName_var')]"
"value": "[variables('uniqueStorageName')]"
},
{
"name": "StorageKey",
@ -333,7 +309,7 @@
},
{
"name": "DBHostName",
"value": "[format('{0}.mysql.database.azure.com', variables('serverName_var'))]"
"value": "[format('{0}.mysql.database.azure.com', variables('uniqueServerName'))]"
},
{
"name": "DBName",
@ -341,12 +317,16 @@
},
{
"name": "DBUserName",
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('serverName_var'))]"
"value": "[parameters('administratorLogin')]"
},
{
"name": "DBPassword",
"value": "[parameters('administratorLoginPassword')]"
},
{
"name": "DBSslCa",
"value": "/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem"
},
{
"name": "PHP_INI_SCAN_DIR",
"value": "/usr/local/etc/php/conf.d:/home/site"
@ -379,15 +359,15 @@
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName_var'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageName_var'))]"
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanNameCleaned'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('uniqueStorageName'))]"
]
},
{
"type": "Microsoft.Web/sites/sourcecontrols",
"apiVersion": "2015-08-01",
"name": "[format('{0}/{1}', variables('webSiteName_var'), 'web')]",
"location": "[resourceGroup().location]",
"name": "[format('{0}/{1}', variables('uniqueWebSiteName'), 'web')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "CodeDeploy"
},
@ -397,15 +377,15 @@
"isManualIntegration": true
},
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', variables('serverName_var'))]",
"[resourceId('Microsoft.Web/sites', variables('webSiteName_var'))]"
"[resourceId('Microsoft.DBforMySQL/flexibleServers', variables('uniqueServerName'))]",
"[resourceId('Microsoft.Web/sites', variables('uniqueWebSiteName'))]"
]
},
{
"type": "Microsoft.DBforMySQL/servers",
"apiVersion": "2017-12-01-preview",
"name": "[variables('serverName_var')]",
"location": "[resourceGroup().location]",
"type": "Microsoft.DBforMySQL/flexibleServers",
"apiVersion": "2021-12-01-preview",
"name": "[variables('uniqueServerName')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "MySQLAzure"
},
@ -413,67 +393,68 @@
"version": "[parameters('mysqlVersion')]",
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"storageProfile": {
"storageMB": "[parameters('databaseSkuSizeMB')]",
"backupRetentionDays": "7",
"storage": {
"storageSizeGB": "[parameters('databaseStorageSize')]",
"iops": "[parameters('databaseStorageIops')]",
"autoGrow": "[parameters('databaseStorageAutoGrow')]",
"autoIoScaling": "[parameters('databseStorageAutoIoScaling')]"
},
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"sslEnforcement": "Disabled"
"highAvailability": {
"mode": "Disabled"
},
"replicationRole": "None"
},
"sku": {
"name": "[variables('databaseForMySqlSku')]"
"name": "Standard_B1ms",
"tier": "Burstable"
}
},
{
"type": "Microsoft.DBforMySQL/servers/firewallRules",
"apiVersion": "2017-12-01-preview",
"name": "[format('{0}/{1}', variables('serverName_var'), 'AllowAzureIPs')]",
"location": "[resourceGroup().location]",
"type": "Microsoft.DBforMySQL/flexibleServers/firewallRules",
"apiVersion": "2021-12-01-preview",
"name": "[format('{0}/{1}', variables('uniqueServerName'), 'AllowAzureIPs')]",
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0"
},
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', variables('serverName_var'))]",
"[resourceId('Microsoft.DBforMySQL/servers/databases', variables('serverName_var'), format('{0}', variables('databaseName')))]"
"[resourceId('Microsoft.DBforMySQL/flexibleServers', variables('uniqueServerName'))]",
"[resourceId('Microsoft.DBforMySQL/flexibleServers/databases', variables('uniqueServerName'), variables('databaseName'))]"
]
},
{
"type": "Microsoft.DBforMySQL/servers/databases",
"apiVersion": "2017-12-01",
"name": "[format('{0}/{1}', variables('serverName_var'), format('{0}', variables('databaseName')))]",
"tags": {
"displayName": "DB"
},
"type": "Microsoft.DBforMySQL/flexibleServers/databases",
"apiVersion": "2021-12-01-preview",
"name": "[format('{0}/{1}', variables('uniqueServerName'), variables('databaseName'))]",
"properties": {
"charset": "utf8",
"collation": "utf8_general_ci"
},
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', variables('serverName_var'))]"
"[resourceId('Microsoft.DBforMySQL/flexibleServers', variables('uniqueServerName'))]"
]
}
],
"outputs": {
"MySQLHostName": {
"type": "string",
"value": "[format('{0}.mysql.database.azure.com', variables('serverName_var'))]"
"value": "[format('{0}.mysql.database.azure.com', variables('uniqueServerName'))]"
},
"MySqlUserName": {
"type": "string",
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('serverName_var'))]"
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('uniqueServerName'))]"
},
"webSiteFQDN": {
"type": "string",
"value": "[format('{0}.azurewebsites.net', variables('webSiteName_var'))]"
},
"storageAccountKey": {
"type": "string",
"value": "[concat(listKeys(variables('storageAccountId'), '2015-05-01-preview').key1)]"
"value": "[format('{0}.azurewebsites.net', variables('uniqueWebSiteName'))]"
},
"storageAccountName": {
"type": "string",
"value": "[variables('storageName_var')]"
"value": "[variables('uniqueStorageName')]"
},
"storageContainerName": {
"type": "string",

Просмотреть файл

@ -44,17 +44,17 @@
"skuCapacity": {
"value": 1
},
"databaseSkuSizeMB": {
"value": 5120
"databaseStorageSizeGB": {
"value": 32
},
"databaseForMySqlTier": {
"value": "GeneralPurpose"
"databaseStorageIops": {
"value": 396
},
"databaseForMySqlFamily": {
"value": "Gen5"
"databaseStorageAutoGrow": {
"value": "Enabled"
},
"databaseForMySqlCores": {
"value": 2
"databseStorageAutoIoScaling": {
"value": "Enabled"
},
"mysqlVersion": {
"value": "5.7"

Просмотреть файл

@ -1,3 +1,5 @@
param location string = resourceGroup().location
@description('Name of azure web app')
param siteName string
@ -52,34 +54,23 @@ param skuName string = 'S1'
@minValue(1)
param skuCapacity int = 1
@description('Azure database for MySQL sku Size ')
param databaseSkuSizeMB int = 5120
@description('Initial MySQL database storage size in GB ')
param databaseStorageSizeGB int = 32
@description('Select MySql server performance tier. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region.')
@allowed([
'Basic'
'GeneralPurpose'
'MemoryOptimized'
])
param databaseForMySqlTier string = 'GeneralPurpose'
@description('Initial MySQL databse storage IOPS')
param databaseStorageIops int = 396
@description('Select MySql compute generation. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region.')
@allowed([
'Gen4'
'Gen5'
'Enabled'
'Disabled'
])
param databaseForMySqlFamily string = 'Gen5'
param databaseStorageAutoGrow string = 'Enabled'
@description('Select MySql vCore count. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region.')
@allowed([
1
2
4
8
16
32
'Enabled'
'Disabled'
])
param databaseForMySqlCores int = 2
param databseStorageAutoIoScaling string = 'Enabled'
@description('MySQL version')
@allowed([
@ -107,24 +98,18 @@ param repoURL string = 'https://github.com/microsoft/azure-redcap-paas.git'
@description('The main branch of the application repo')
param branch string = 'main'
var siteName_var = replace(siteName, ' ', '')
var databaseName = '${siteName_var}_db'
var serverName_var = concat(siteName_var, uniqueString(resourceGroup().id))
var hostingPlanName_var = '${siteName_var}_serviceplan'
var sendgridAccountName_var = '${siteName_var}_sendgrid'
var webSiteName_var = concat(siteName_var, uniqueString(resourceGroup().id))
var tierSymbol = {
Basic: 'B'
GeneralPurpose: 'GP'
MemoryOptimized: 'MO'
}
var databaseForMySqlSku = '${tierSymbol[databaseForMySqlTier]}_${databaseForMySqlFamily}_${databaseForMySqlCores}'
var storageName_var = 'storage${uniqueString(resourceGroup().id)}'
var storageAccountId = '${resourceGroup().id}/providers/Microsoft.Storage/storageAccounts/${storageName_var}'
var siteNameCleaned = replace(siteName, ' ', '')
var databaseName = '${siteNameCleaned}_db'
var uniqueServerName = '${siteNameCleaned}${uniqueString(resourceGroup().id)}'
var hostingPlanNameCleaned = '${siteNameCleaned}_serviceplan'
var uniqueSendgridAccountName = '${siteNameCleaned}_sendgrid'
var uniqueWebSiteName = '${siteNameCleaned}${uniqueString(resourceGroup().id)}'
var uniqueStorageName = 'storage${uniqueString(resourceGroup().id)}'
var storageAccountId = '${resourceGroup().id}/providers/Microsoft.Storage/storageAccounts/${uniqueStorageName}'
resource sendgridAccountName 'Sendgrid.Email/accounts@2015-01-01' = {
name: sendgridAccountName_var
location: resourceGroup().location
name: uniqueSendgridAccountName
location: location
tags: {
displayName: 'SendGrid'
}
@ -142,8 +127,8 @@ resource sendgridAccountName 'Sendgrid.Email/accounts@2015-01-01' = {
}
resource storageName 'Microsoft.Storage/storageAccounts@2016-01-01' = {
name: storageName_var
location: resourceGroup().location
name: uniqueStorageName
location: location
sku: {
name: storageType
}
@ -165,8 +150,8 @@ resource storageContainer 'Microsoft.Storage/storageAccounts/blobServices/contai
}
resource hostingPlanName 'Microsoft.Web/serverfarms@2016-09-01' = {
name: hostingPlanName_var
location: resourceGroup().location
name: hostingPlanNameCleaned
location: location
tags: {
displayName: 'HostingPlan'
}
@ -176,27 +161,27 @@ resource hostingPlanName 'Microsoft.Web/serverfarms@2016-09-01' = {
}
kind: 'linux'
properties: {
name: hostingPlanName_var
name: hostingPlanNameCleaned
reserved: true
}
}
resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
name: webSiteName_var
location: resourceGroup().location
name: uniqueWebSiteName
location: location
tags: {
displayName: 'WebApp'
}
properties: {
name: webSiteName_var
serverFarmId: hostingPlanName_var
name: uniqueWebSiteName
serverFarmId: hostingPlanNameCleaned
siteConfig: {
linuxFxVersion: linuxFxVersion
alwaysOn: true
connectionStrings: [
{
name: 'defaultConnection'
connectionString: 'Database=${databaseName};Data Source=${serverName_var}.mysql.database.azure.com;User Id=${administratorLogin}@${serverName_var};Password=${administratorLoginPassword}'
connectionString: 'Database=${databaseName};Data Source=${uniqueServerName}.mysql.database.azure.com;User Id=${administratorLogin}@${uniqueServerName};Password=${administratorLoginPassword}'
type: 'MySql'
}
]
@ -208,7 +193,7 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
}
{
name: 'StorageAccount'
value: storageName_var
value: uniqueStorageName
}
{
name: 'StorageKey'
@ -232,7 +217,7 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
}
{
name: 'DBHostName'
value: '${serverName_var}.mysql.database.azure.com'
value: '${uniqueServerName}.mysql.database.azure.com'
}
{
name: 'DBName'
@ -240,12 +225,16 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
}
{
name: 'DBUserName'
value: '${administratorLogin}@${serverName_var}'
value: '${administratorLogin}@${uniqueServerName}'
}
{
name: 'DBPassword'
value: administratorLoginPassword
}
{
name: 'DBSslCa'
value: '/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem'
}
{
name: 'PHP_INI_SCAN_DIR'
value: '/usr/local/etc/php/conf.d:/home/site'
@ -286,7 +275,7 @@ resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
resource webSiteName_web 'Microsoft.Web/sites/sourcecontrols@2015-08-01' = {
parent: webSiteName
name: 'web'
location: resourceGroup().location
location: location
tags: {
displayName: 'CodeDeploy'
}
@ -300,9 +289,9 @@ resource webSiteName_web 'Microsoft.Web/sites/sourcecontrols@2015-08-01' = {
]
}
resource serverName 'Microsoft.DBforMySQL/servers@2017-12-01-preview' = {
location: resourceGroup().location
name: serverName_var
resource serverName 'Microsoft.DBforMySQL/flexibleServers@2021-12-01-preview' = {
location: location
name: uniqueServerName
tags: {
displayName: 'MySQLAzure'
}
@ -310,21 +299,29 @@ resource serverName 'Microsoft.DBforMySQL/servers@2017-12-01-preview' = {
version: mysqlVersion
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
storageProfile: {
storageMB: databaseSkuSizeMB
backupRetentionDays: '7'
storage: {
storageSizeGB: databaseStorageSizeGB
iops: databaseStorageIops
autoGrow: databaseStorageAutoGrow
autoIoScaling: databseStorageAutoIoScaling
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
sslEnforcement: 'Disabled'
highAvailability: {
mode: 'Disabled'
}
replicationRole: 'None'
}
sku: {
name: databaseForMySqlSku
name: 'Standard_B1ms'
tier: 'Burstable'
}
}
resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/servers/firewallrules@2017-12-01-preview' = {
resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/flexibleServers/firewallRules@2021-12-01-preview' = {
parent: serverName
location: resourceGroup().location
name: 'AllowAzureIPs'
properties: {
startIpAddress: '0.0.0.0'
@ -335,22 +332,18 @@ resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/servers/firewallrules@20
]
}
resource serverName_databaseName 'Microsoft.DBforMySQL/servers/databases@2017-12-01' = {
resource serverName_databaseName 'Microsoft.DBforMySQL/flexibleServers/databases@2021-12-01-preview' = {
parent: serverName
name: '${databaseName}'
tags: {
displayName: 'DB'
}
name: databaseName
properties: {
charset: 'utf8'
collation: 'utf8_general_ci'
}
}
output MySQLHostName string = '${serverName_var}.mysql.database.azure.com'
output MySqlUserName string = '${administratorLogin}@${serverName_var}'
output webSiteFQDN string = '${webSiteName_var}.azurewebsites.net'
output storageAccountKey string = concat(listKeys(storageAccountId, '2015-05-01-preview').key1)
output storageAccountName string = storageName_var
output MySQLHostName string = '${uniqueServerName}.mysql.database.azure.com'
output MySqlUserName string = '${administratorLogin}@${uniqueServerName}'
output webSiteFQDN string = '${uniqueWebSiteName}.azurewebsites.net'
output storageAccountName string = uniqueStorageName
output storageContainerName string = storageContainerName
output SendGrid object = sendgridAccountName.properties

Просмотреть файл

@ -4,11 +4,15 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.7.4.23292",
"templateHash": "10974727704408636365"
"version": "0.14.6.61914",
"templateHash": "14853070812822277948"
}
},
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"siteName": {
"type": "string",
"metadata": {
@ -31,7 +35,7 @@
}
},
"administratorLoginPassword": {
"type": "secureString",
"type": "securestring",
"minLength": 8,
"metadata": {
"description": "Password used for database administration and SendGrid email access"
@ -51,7 +55,7 @@
}
},
"redcapCommunityPassword": {
"type": "secureString",
"type": "securestring",
"metadata": {
"description": "REDCap Community site password for downloading the REDCap zip file."
}
@ -100,51 +104,36 @@
"description": "Describes plan's instance count (how many distinct web servers will be deployed in the farm) - this can be changed after deployment"
}
},
"databaseSkuSizeMB": {
"databaseStorageSizeGB": {
"type": "int",
"defaultValue": 5120,
"defaultValue": 32,
"metadata": {
"description": "Azure database for MySQL sku Size "
"description": "Initial MySQL database storage size in GB "
}
},
"databaseForMySqlTier": {
"type": "string",
"defaultValue": "GeneralPurpose",
"allowedValues": [
"Basic",
"GeneralPurpose",
"MemoryOptimized"
],
"metadata": {
"description": "Select MySql server performance tier. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region."
}
},
"databaseForMySqlFamily": {
"type": "string",
"defaultValue": "Gen5",
"allowedValues": [
"Gen4",
"Gen5"
],
"metadata": {
"description": "Select MySql compute generation. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region."
}
},
"databaseForMySqlCores": {
"databaseStorageIops": {
"type": "int",
"defaultValue": 2,
"allowedValues": [
1,
2,
4,
8,
16,
32
],
"defaultValue": 396,
"metadata": {
"description": "Select MySql vCore count. Please review https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers and ensure your choices are available in the selected region."
"description": "Initial MySQL databse storage IOPS"
}
},
"databaseStorageAutoGrow": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [
"Enabled",
"Disabled"
]
},
"databseStorageAutoIoScaling": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [
"Enabled",
"Disabled"
]
},
"mysqlVersion": {
"type": "string",
"defaultValue": "5.7",
@ -193,27 +182,21 @@
}
},
"variables": {
"siteName_var": "[replace(parameters('siteName'), ' ', '')]",
"databaseName": "[format('{0}_db', variables('siteName_var'))]",
"serverName_var": "[concat(variables('siteName_var'), uniqueString(resourceGroup().id))]",
"hostingPlanName_var": "[format('{0}_serviceplan', variables('siteName_var'))]",
"sendgridAccountName_var": "[format('{0}_sendgrid', variables('siteName_var'))]",
"webSiteName_var": "[concat(variables('siteName_var'), uniqueString(resourceGroup().id))]",
"tierSymbol": {
"Basic": "B",
"GeneralPurpose": "GP",
"MemoryOptimized": "MO"
},
"databaseForMySqlSku": "[format('{0}_{1}_{2}', variables('tierSymbol')[parameters('databaseForMySqlTier')], parameters('databaseForMySqlFamily'), parameters('databaseForMySqlCores'))]",
"storageName_var": "[format('storage{0}', uniqueString(resourceGroup().id))]",
"storageAccountId": "[format('{0}/providers/Microsoft.Storage/storageAccounts/{1}', resourceGroup().id, variables('storageName_var'))]"
"siteNameCleaned": "[replace(parameters('siteName'), ' ', '')]",
"databaseName": "[format('{0}_db', variables('siteNameCleaned'))]",
"uniqueServerName": "[format('{0}{1}', variables('siteNameCleaned'), uniqueString(resourceGroup().id))]",
"hostingPlanNameCleaned": "[format('{0}_serviceplan', variables('siteNameCleaned'))]",
"uniqueSendgridAccountName": "[format('{0}_sendgrid', variables('siteNameCleaned'))]",
"uniqueWebSiteName": "[format('{0}{1}', variables('siteNameCleaned'), uniqueString(resourceGroup().id))]",
"uniqueStorageName": "[format('storage{0}', uniqueString(resourceGroup().id))]",
"storageAccountId": "[format('{0}/providers/Microsoft.Storage/storageAccounts/{1}', resourceGroup().id, variables('uniqueStorageName'))]"
},
"resources": [
{
"type": "Sendgrid.Email/accounts",
"apiVersion": "2015-01-01",
"name": "[variables('sendgridAccountName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('uniqueSendgridAccountName')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "SendGrid"
},
@ -232,8 +215,8 @@
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2016-01-01",
"name": "[variables('storageName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('uniqueStorageName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageType')]"
},
@ -245,24 +228,24 @@
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2021-09-01",
"name": "[format('{0}/{1}', variables('storageName_var'), 'default')]",
"name": "[format('{0}/{1}', variables('uniqueStorageName'), 'default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageName_var'))]"
"[resourceId('Microsoft.Storage/storageAccounts', variables('uniqueStorageName'))]"
]
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2021-09-01",
"name": "[format('{0}/{1}/{2}', variables('storageName_var'), 'default', parameters('storageContainerName'))]",
"name": "[format('{0}/{1}/{2}', variables('uniqueStorageName'), 'default', parameters('storageContainerName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('storageName_var'), 'default')]"
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('uniqueStorageName'), 'default')]"
]
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2016-09-01",
"name": "[variables('hostingPlanName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('hostingPlanNameCleaned')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "HostingPlan"
},
@ -272,28 +255,28 @@
},
"kind": "linux",
"properties": {
"name": "[variables('hostingPlanName_var')]",
"name": "[variables('hostingPlanNameCleaned')]",
"reserved": true
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"name": "[variables('webSiteName_var')]",
"location": "[resourceGroup().location]",
"name": "[variables('uniqueWebSiteName')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "WebApp"
},
"properties": {
"name": "[variables('webSiteName_var')]",
"serverFarmId": "[variables('hostingPlanName_var')]",
"name": "[variables('uniqueWebSiteName')]",
"serverFarmId": "[variables('hostingPlanNameCleaned')]",
"siteConfig": {
"linuxFxVersion": "[parameters('linuxFxVersion')]",
"alwaysOn": true,
"connectionStrings": [
{
"name": "defaultConnection",
"connectionString": "[format('Database={0};Data Source={1}.mysql.database.azure.com;User Id={2}@{3};Password={4}', variables('databaseName'), variables('serverName_var'), parameters('administratorLogin'), variables('serverName_var'), parameters('administratorLoginPassword'))]",
"connectionString": "[format('Database={0};Data Source={1}.mysql.database.azure.com;User Id={2}@{3};Password={4}', variables('databaseName'), variables('uniqueServerName'), parameters('administratorLogin'), variables('uniqueServerName'), parameters('administratorLoginPassword'))]",
"type": "MySql"
}
],
@ -305,7 +288,7 @@
},
{
"name": "StorageAccount",
"value": "[variables('storageName_var')]"
"value": "[variables('uniqueStorageName')]"
},
{
"name": "StorageKey",
@ -329,7 +312,7 @@
},
{
"name": "DBHostName",
"value": "[format('{0}.mysql.database.azure.com', variables('serverName_var'))]"
"value": "[format('{0}.mysql.database.azure.com', variables('uniqueServerName'))]"
},
{
"name": "DBName",
@ -337,12 +320,16 @@
},
{
"name": "DBUserName",
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('serverName_var'))]"
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('uniqueServerName'))]"
},
{
"name": "DBPassword",
"value": "[parameters('administratorLoginPassword')]"
},
{
"name": "DBSslCa",
"value": "/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem"
},
{
"name": "PHP_INI_SCAN_DIR",
"value": "/usr/local/etc/php/conf.d:/home/site"
@ -353,7 +340,7 @@
},
{
"name": "smtp_fqdn_name",
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName_var'))).smtpServer]"
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('uniqueSendgridAccountName')), '2015-01-01').smtpServer]"
},
{
"name": "smtp_port",
@ -361,7 +348,7 @@
},
{
"name": "smtp_user_name",
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName_var'))).username]"
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('uniqueSendgridAccountName')), '2015-01-01').username]"
},
{
"name": "smtp_password",
@ -375,16 +362,16 @@
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName_var'))]",
"[resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName_var'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageName_var'))]"
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanNameCleaned'))]",
"[resourceId('Sendgrid.Email/accounts', variables('uniqueSendgridAccountName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('uniqueStorageName'))]"
]
},
{
"type": "Microsoft.Web/sites/sourcecontrols",
"apiVersion": "2015-08-01",
"name": "[format('{0}/{1}', variables('webSiteName_var'), 'web')]",
"location": "[resourceGroup().location]",
"name": "[format('{0}/{1}', variables('uniqueWebSiteName'), 'web')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "CodeDeploy"
},
@ -394,15 +381,15 @@
"isManualIntegration": true
},
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', variables('serverName_var'))]",
"[resourceId('Microsoft.Web/sites', variables('webSiteName_var'))]"
"[resourceId('Microsoft.DBforMySQL/flexibleServers', variables('uniqueServerName'))]",
"[resourceId('Microsoft.Web/sites', variables('uniqueWebSiteName'))]"
]
},
{
"type": "Microsoft.DBforMySQL/servers",
"apiVersion": "2017-12-01-preview",
"name": "[variables('serverName_var')]",
"location": "[resourceGroup().location]",
"type": "Microsoft.DBforMySQL/flexibleServers",
"apiVersion": "2021-12-01-preview",
"name": "[variables('uniqueServerName')]",
"location": "[parameters('location')]",
"tags": {
"displayName": "MySQLAzure"
},
@ -410,67 +397,68 @@
"version": "[parameters('mysqlVersion')]",
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"storageProfile": {
"storageMB": "[parameters('databaseSkuSizeMB')]",
"backupRetentionDays": "7",
"storage": {
"storageSizeGB": "[parameters('databaseStorageSizeGB')]",
"iops": "[parameters('databaseStorageIops')]",
"autoGrow": "[parameters('databaseStorageAutoGrow')]",
"autoIoScaling": "[parameters('databseStorageAutoIoScaling')]"
},
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
},
"sslEnforcement": "Disabled"
"highAvailability": {
"mode": "Disabled"
},
"replicationRole": "None"
},
"sku": {
"name": "[variables('databaseForMySqlSku')]"
"name": "Standard_B1ms",
"tier": "Burstable"
}
},
{
"type": "Microsoft.DBforMySQL/servers/firewallRules",
"apiVersion": "2017-12-01-preview",
"name": "[format('{0}/{1}', variables('serverName_var'), 'AllowAzureIPs')]",
"location": "[resourceGroup().location]",
"type": "Microsoft.DBforMySQL/flexibleServers/firewallRules",
"apiVersion": "2021-12-01-preview",
"name": "[format('{0}/{1}', variables('uniqueServerName'), 'AllowAzureIPs')]",
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0"
},
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', variables('serverName_var'))]",
"[resourceId('Microsoft.DBforMySQL/servers/databases', variables('serverName_var'), format('{0}', variables('databaseName')))]"
"[resourceId('Microsoft.DBforMySQL/flexibleServers', variables('uniqueServerName'))]",
"[resourceId('Microsoft.DBforMySQL/flexibleServers/databases', variables('uniqueServerName'), variables('databaseName'))]"
]
},
{
"type": "Microsoft.DBforMySQL/servers/databases",
"apiVersion": "2017-12-01",
"name": "[format('{0}/{1}', variables('serverName_var'), format('{0}', variables('databaseName')))]",
"tags": {
"displayName": "DB"
},
"type": "Microsoft.DBforMySQL/flexibleServers/databases",
"apiVersion": "2021-12-01-preview",
"name": "[format('{0}/{1}', variables('uniqueServerName'), variables('databaseName'))]",
"properties": {
"charset": "utf8",
"collation": "utf8_general_ci"
},
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', variables('serverName_var'))]"
"[resourceId('Microsoft.DBforMySQL/flexibleServers', variables('uniqueServerName'))]"
]
}
],
"outputs": {
"MySQLHostName": {
"type": "string",
"value": "[format('{0}.mysql.database.azure.com', variables('serverName_var'))]"
"value": "[format('{0}.mysql.database.azure.com', variables('uniqueServerName'))]"
},
"MySqlUserName": {
"type": "string",
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('serverName_var'))]"
"value": "[format('{0}@{1}', parameters('administratorLogin'), variables('uniqueServerName'))]"
},
"webSiteFQDN": {
"type": "string",
"value": "[format('{0}.azurewebsites.net', variables('webSiteName_var'))]"
},
"storageAccountKey": {
"type": "string",
"value": "[concat(listKeys(variables('storageAccountId'), '2015-05-01-preview').key1)]"
"value": "[format('{0}.azurewebsites.net', variables('uniqueWebSiteName'))]"
},
"storageAccountName": {
"type": "string",
"value": "[variables('storageName_var')]"
"value": "[variables('uniqueStorageName')]"
},
"storageContainerName": {
"type": "string",
@ -478,7 +466,7 @@
},
"SendGrid": {
"type": "object",
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName_var')))]"
"value": "[reference(resourceId('Sendgrid.Email/accounts', variables('uniqueSendgridAccountName')), '2015-01-01')]"
}
}
}

Просмотреть файл

@ -1,345 +0,0 @@
$global:ProgressPreference = "SilentlyContinue"
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
Add-Type -AssemblyName System.Net.Http
$path = "$($env:HOME)\site\repository"
$webRoot = "$($env:HOME)\site\wwwroot"
[System.Reflection.Assembly]::LoadFrom("$path\Files\mysql\MySql.Data.dll") | Out-Null
$dbver=""
$zipUri = "$env:APPSETTING_redcapAppZip"
$zipUsername = "$env:APPSETTING_redcapCommunityUsername"
$zipPassword = "$env:APPSETTING_redcapCommunityPassword"
$zipVersion = "$env:APPSETTING_redcapAppZipVersion"
$stamp=(Get-Date).toString("yyyy-MM-dd-HH-mm-ss")
$logFile = "$path\log-$stamp.txt"
Set-Content "$($env:HOME)\site\repository\currlogname.txt" -Value $logFile -NoNewline
Write-Output "loading functions"
function Main {
try {
Copy-Item -Path "$path\Files\AzDeployStatus.php" -Destination "$webRoot\AzDeployStatus.php"
Log("Checking ZIP file name and version")
$filename = GetFileName
$filePath = "$path\$filename"
$version = $filename.Replace(".zip","")
$dbver = $version.Replace("redcap","")
Log("Processing $version")
if (-Not (Test-Path "$filePath")) {
Log("Downloading $filename")
# Download the ZIP file
DownloadFile($filePath)
Log("Unzipping file")
mkdir "$path\target" -ErrorAction SilentlyContinue
Expand-Archive $filePath -DestinationPath "$path\target\$version" -Force
# reset RO attributes on some files
Log("Resetting file attributes")
attrib -r "$path\target\$version\redcap\webtools2\pdf\font\unifont\*.*" /S
# clean up www
Log("Cleaning up existing web root")
Get-ChildItem -Path $webRoot -Recurse -Exclude "AzDeployStatus.php" |
Select-Object -ExpandProperty FullName |
Sort-Object length -Descending |
Remove-Item -force
# copy app files to wwwroot
Log("Moving files to web root")
MoveFiles
# initialize PHP_INI_SYSTEM settings
# https://docs.microsoft.com/en-us/azure/app-service/web-sites-php-configure#changing-phpinisystem-configuration-settings
Log("Updating PHP and sendmail settings")
UpdatePHPSettings
# Add container to new storage account
Log("Creating Azure Blob Storage container")
CreateContainer
# Update database config
Log("Updating MySql DB connection settings")
UpdateDBConnection
# Apply schema
Log("Applying schema to new database (this could take several minutes)")
ApplySchema
# Update app config
Log("Updating configuration in redcap_config")
UpdateConfig
# Setup Web Job
Log("Setting up web job")
SetupWebJob
# add web.config to clean up MIME types in IIS
Log("Copying web.config")
Copy-Item -Path "$path\Files\web.config" -Destination "$webRoot\web.config"
Log("Deployment complete")
Log("Stopping W3WP process to force reload of PHP settings (process will restart automatically)")
Start-Job -ScriptBlock {
Start-Sleep -Seconds 2;
Stop-Process -Name w3wp -ErrorAction Ignore
}
} else {
Write-Output "File $filename already present"
}
}
catch {
Log("An error occured and deployment may not have completed successfully. Try loading the home page to see if the database is connected. The detailed error message is below:<br>")
Log($_.Exception)
Exit 1
}
}
function SetupWebJob {
$webJobDir = "$webRoot\App_Data\jobs\triggered\CronWebJob";
mkdir $webJobDir;
Copy-Item -Path "$path\Files\WebJob\cronWebJob.ps1" -Destination $webJobDir
Copy-Item -Path "$path\Files\WebJob\settings.job" -Destination $webJobDir
}
function CreateContainer {
$storageCtx = New-AzureStorageContext -StorageAccountName $env:APPSETTING_StorageAccount -StorageAccountKey $env:APPSETTING_StorageKey
New-AzureStorageContainer -Name $env:APPSETTING_StorageContainerName -Context $storageCtx
}
function ApplySchema {
#Get schema
$sql = GetSQLSchema
Log("Schema retrieved from site, applying...")
CallSql -Query $sql
Log("Completed applying schema")
}
function UpdateConfig {
Log("Updating site configuration in database")
CallSql -Query "UPDATE $($env:APPSETTING_DBName).redcap_config SET value ='https://$($env:WEBSITE_HOSTNAME)/' WHERE field_name = 'redcap_base_url';"
Log("Updating storage configuration in database")
$sqlList = @(
#storage
"UPDATE $($env:APPSETTING_DBName).redcap_config SET value ='$env:APPSETTING_StorageAccount' WHERE field_name = 'azure_app_name';",
"UPDATE $($env:APPSETTING_DBName).redcap_config SET value ='$env:APPSETTING_StorageKey' WHERE field_name = 'azure_app_secret';",
"UPDATE $($env:APPSETTING_DBName).redcap_config SET value ='$env:APPSETTING_StorageContainerName' WHERE field_name = 'azure_container';"
"UPDATE $($env:APPSETTING_DBName).redcap_config SET value ='4' WHERE field_name = 'edoc_storage_option';"
"REPLACE INTO $($env:APPSETTING_DBName).redcap_config (field_name, value) VALUES ('azure_quickstart', '1');"
)
$sqlStr = $sqlList -join "`r`n" | Out-String
#SilentlyContinue should accomodate earlier versions that don't have direct support for Azure storage
CallSql -Query $sqlStr -ErrorAction SilentlyContinue
Log("Completed updating configuration")
}
function CallSql {
param(
[parameter(Position=0, Mandatory=$true)]
[string]$Query
)
$cs = "Server=$env:APPSETTING_DBHostName;Port=3306;Allow Batch=true;default command timeout=900;Allow User Variables=true;Connection Timeout=600;Uid=$env:APPSETTING_DBUserName;Pwd=$env:APPSETTING_DBPassword;Database=$env:APPSETTING_DBName;"
$cn = New-Object MySql.Data.MySqlClient.MySqlConnection
$cn.ConnectionString = $cs
$cn.Open()
$cmd= New-Object MySql.Data.MySqlClient.MySqlCommand
$cmd.Connection = $cn
$cmd.CommandType = [System.Data.CommandType]::Text
$cmd.CommandTimeout = 30000
$cmd.CommandText = $Query
$cmd.ExecuteNonQuery()
$cmd.Dispose()
$cn.Close()
$cn.Dispose()
}
function UpdatePHPSettings {
$sendmailiniFileName = "$path\Files\sendmail\sendmail.ini"
Log("Updating $sendmailiniFileName with assigned variables")
$sendmailiniFile = [System.Io.File]::ReadAllText($sendmailiniFileName)
$sendmailiniFile = $sendmailiniFile.Replace('replace_smtp_server_name',"$env:APPSETTING_smtp_fqdn_name").Replace('replace_smtp_port', "$env:APPSETTING_smtp_port").Replace('replace_smtp_force_sender', "$env:APPSETTING_from_email_address").Replace('replace_smtp_username', "$env:APPSETTING_smtp_user_name").Replace('replace_smtp_password', "$env:APPSETTING_smtp_password");
$sendmailiniFile | Set-Content $sendmailiniFileName
$iniFolder = "$($env:HOME)\site\ini"
mkdir $iniFolder
$settingsFileName = "$path\Files\settings.ini"
Log("Updating $settingsFileName with assigned variables")
$settingsFile = [System.Io.File]::ReadAllText($settingsFileName)
$settingsFile = $settingsFile.Replace('replace_smtp_server_name',"$env:APPSETTING_smtp_fqdn_name").Replace('replace_smtp_port', "$env:APPSETTING_smtp_port").Replace('replace_sendmail_from', "$env:APPSETTING_from_email_address").Replace('replace_sendmail_path', "$path\Files\sendmail\sendmail.exe -t -i");
$settingsFile | Set-Content $settingsFileName
Copy-Item $settingsFileName "$iniFolder\settings.ini"
}
function UpdateDBConnection {
$dbFilename = "$webRoot\database.php"
Log("Updating $dbFilename with assigned variables")
$bytes = New-Object Byte[] 8
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$newsalt = [System.Convert]::ToBase64String($bytes)
$dbFile = [System.Io.File]::ReadAllText($dbFilename)
$dbFile = $dbFile.Replace('your_mysql_host_name',"$env:APPSETTING_DBHostName").Replace('your_mysql_db_name', "$env:APPSETTING_DBName").Replace('your_mysql_db_username', "$env:APPSETTING_DBUserName").Replace('your_mysql_db_password', "$env:APPSETTING_DBPassword").Replace("`$salt = ''", "`$salt = '$newsalt'");
$dbFile | Set-Content $dbFilename
}
function GetSQLSchema {
$body = @{
"version" = $dbver
}
$res = Invoke-WebRequest `
-UseBasicParsing `
-Uri "https://$($env:WEBSITE_HOSTNAME)/install.php" `
-Body $body `
-Method Post
$str = $res.Content
$start = $str.IndexOf("<textarea ")
$end = $str.IndexOf("</textarea>")
$new = $str.substring($start, ($end - $start))
$sql = $new -replace("<textarea[^>]*>","")
#save the schema for posterity
$sql | Out-File schema.sql
return $sql
}
function MoveFiles {
$source = "$path\target\$version\redcap"
$dest = $webRoot
$what = @("*.*","/E","/MOVE","/NFL","/NDL","NJH","NP","/LOG+:`"$logFile`"")
$cmdArgs = @("$source","$dest",$what)
robocopy @cmdArgs
Log("RoboCopy output: $($rcOutput[$LASTEXITCODE])")
}
function DownloadFile($filePath) {
#if the zip file is not null or empty
#then download zip from location
#else attempt to download zip file from redcap community site
if (-Not [string]::IsNullOrEmpty($zipUri)) {
Invoke-WebRequest $zipUri -OutFile $filePath
} else {
if ([string]::IsNullOrEmpty($zipUsername)) {
throw "Missing REDCap Community site username."
}
if ([string]::IsNullOrEmpty($zipPassword)) {
throw "Missing REDCap Community site password."
}
if ([string]::IsNullOrEmpty($zipVersion)) {
Write-Host "zipVersion is null or empty. Setting to latest"
$zipVersion = "latest"
}
$zipRequestBody = @{
username=$zipUsername
password=$zipPassword
version=$zipVersion
install='1'}
$zipRequestContentType = 'application/x-www-form-urlencoded'
$zipResponse = Invoke-WebRequest -Method POST -Uri https://redcap.vanderbilt.edu/plugins/redcap_consortium/versions.php -body $zipRequestBody -ContentType $zipRequestContentType -UseBasicParsing
if ($zipResponse.Content.Contains("ERROR")) {
throw $zipResponse.Content
}
else {
Invoke-WebRequest -Method POST -Uri https://redcap.vanderbilt.edu/plugins/redcap_consortium/versions.php -body $zipRequestBody -ContentType $zipRequestContentType -OutFile $filePath
}
}
}
function GetFileName {
if (-Not [string]::IsNullOrEmpty($zipUri)) {
# (HT to https://github.com/SelectDBA for the Split-Path suggestion)
$res = Invoke-WebRequest -Method Head -Uri $zipUri -UseBasicParsing
$header = $res.Headers["content-disposition"]
if ($null -ne $header -and $header.length > 0) {
$filename = [System.Net.Http.Headers.ContentDispositionHeaderValue]::Parse($header).Filename
if ($filename.IndexOf('"') -gt -1) {
$filename = ConvertFrom-Json $filename
}
} else {
$header = $res.Headers.Keys | Where-Object { if($_.contains("filename")){$_}}
if ($null -ne $header -and $header.length > 0) {
$filename = $res.Headers[$header]
} else {
#no content disposition, no filename...try the URL?
$lp = $res.BaseResponse.ResponseUri.LocalPath
$filename = Split-Path $lp -leaf
if ($null -eq $filename -and $filename.length > 0) {
#can't really punt at this point, if we don't have the file name we don't have the version
#and can't initialize the database
throw "Unable to determine the downloaded file name, so can't verify the version number. Please try an alternate method to host your ZIP file."
}
}
}
} elseif (-Not [string]::IsNullOrEmpty($zipVersion)) {
if ($zipVersion -eq "latest") {
$versionsResp = Invoke-WebRequest -Uri https://redcap.vanderbilt.edu/plugins/redcap_consortium/versions.php -UseBasicParsing
$content = ConvertFrom-Json $versionsResp.content
$version = $content.latest_version
$filename = "redcap$version.zip"
} else {
$filename = "redcap$zipVersion.zip"
}
} else {
throw "Unable to downloaded file, so can't verify the version number. Please try an alternate method to host your ZIP file."
}
return $filename
}
function Log($entry) {
$msg = "$((Get-Date).ToString("yyyy/MM/dd HH:mm:ss")) $entry"
Add-Content $logFile -Value $msg | Out-Null
Write-Output $msg
}
function Resolve-Error ($ErrorRecord=$Error[0])
{
$ErrorRecord | Format-List * -Force
$ErrorRecord.InvocationInfo |Format-List *
$Exception = $ErrorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException))
{ "$i" * 80
$Exception |Format-List * -Force
}
}
#https://support.microsoft.com/en-us/help/954404/return-codes-that-are-used-by-the-robocopy-utility-in-windows-server-2
$rcOutput=@{
0 = "No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped.";
1 = "All files were copied successfully.";
2 = "There are some additional files in the destination directory that are not present in the source directory. No files were copied.";
3 = "Some files were copied. Additional files were present. No failure was encountered.";
5 = "Some files were copied. Some files were mismatched. No failure was encountered.";
6 = "Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory.";
7 = "Files were copied, a file mismatch was present, and additional files were present.";
8 = "Several files did not copy.";
}
# Start running deployment
Main

Просмотреть файл

@ -33,8 +33,8 @@ extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/mysqli.so" >>
####################################################################################
cd /tmp
if [ -z "$APPSETTING_redcapAppZip" ]; then
echo "Downloading REDCap zip file from REDCap Community site" >> /home/site/log-$stamp.txt
if [ -z "$APPSETTING_redcapAppZip" ]; then
echo "Downloading REDCap zip file from REDCap Community site" >> /home/site/log-$stamp.txt
if [ -z "$APPSETTING_zipUsername" ]; then
echo "Missing REDCap Community site username." >> /home/site/log-$stamp.txt
@ -78,11 +78,18 @@ rm -Rf /home/site/wwwroot/redcap
####################################################################################
echo "Updating database connection info in database.php" >> /home/site/log-$stamp.txt
cd /home/site/wwwroot
sed -i "s/your_mysql_host_name/$APPSETTING_DBHostName/" database.php
sed -i "s/your_mysql_db_name/$APPSETTING_DBName/" database.php
sed -i "s/your_mysql_db_username/$APPSETTING_DBUserName/" database.php
sed -i "s/your_mysql_db_password/$APPSETTING_DBPassword/" database.php
wget --no-check-certificate https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem
sed -i "s/'your_mysql_host_name'/'$APPSETTING_DBHostName'/" database.php
sed -i "s/'your_mysql_db_name'/'$APPSETTING_DBName'/" database.php
sed -i "s/'your_mysql_db_username'/'$APPSETTING_DBUserName'/" database.php
sed -i "s/'your_mysql_db_password'/'$APPSETTING_DBPassword'/" database.php
sed -i "s|db_ssl_ca[[:space:]]*= '';|db_ssl_ca = '$APPSETTING_DBSslCa';|" database.php
sed -i "s/db_ssl_verify_server_cert = false;/db_ssl_verify_server_cert = true;/" database.php
sed -i "s/$salt = '';/$salt = '$(echo $RANDOM | md5sum | head -c 20; echo;)';/" database.php
####################################################################################
@ -123,4 +130,4 @@ cp /home/site/repository/postbuild.sh /home/site/deployments/tools/PostDeploymen
#
####################################################################################
cp /home/site/repository/startup.sh /home/startup.sh
cp /home/site/repository/startup.sh /home/startup.sh

Просмотреть файл

@ -12,8 +12,7 @@
# user file uploading settings to Azure Blob Storage
#
####################################################################################
mysql -u$APPSETTING_DBUserName -h$APPSETTING_DBHostName -p$APPSETTING_DBPassword <<EOF
mysql -u$APPSETTING_DBUserName -h$APPSETTING_DBHostName -p$APPSETTING_DBPassword --ssl=true --ssl-ca=/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem <<EOF
source /home/install.sql;
UPDATE $APPSETTING_DBName.redcap_config SET value = 'https://$WEBSITE_HOSTNAME/' WHERE field_name = 'redcap_base_url';
UPDATE $APPSETTING_DBName.redcap_config SET value = '$APPSETTING_StorageAccount' WHERE field_name = 'azure_app_name';

Просмотреть файл

@ -13,7 +13,7 @@ echo "hello from postbuild.sh"
#
####################################################################################
apt-get install -y python3-pip
apt-get install -y python3 python3-pip
####################################################################################
#

Просмотреть файл

@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" {
constraints = "<= 2.99.0"
hashes = [
"h1:/M8yLHqv0uOm9IbHRa4yZvQORr9ir1QyJyIyjGs4ryQ=",
"h1:FXBB5TkvZpZA+ZRtofPvp5IHZpz4Atw7w9J8GDgMhvk=",
"zh:08d81e72e97351538ab4d15548942217bf0c4d3b79ad3f4c95d8f07f902d2fa6",
"zh:11fdfa4f42d6b6f01371f336fea56f28a1db9e7b490c5ca0b352f6bbca5a27f1",
"zh:12376e2c4b56b76098d5d713d1a4e07e748a926c4d165f0bd6f52157b1f7a7e9",
@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/http" {
version = "2.2.0"
hashes = [
"h1:EiuCPEHueILwdgK4hnWuLyT/XdB5ZbEY8ALZdCJYcYM=",
"h1:syLdPUKrNIJ7mF7+ijSSUot8VIuFL/45kbN5UcHEIvU=",
"zh:159add5739a597c08439318f67c440a90ce8444a009e7b8aabbcb9279da9191f",
"zh:1e5fbe9a4b8d3d9f167effc03bd5324ad6ef721c23a174e98c7eb2e8b85e34e8",
"zh:4b150790ac5948ceec4f97df4deaff835e4798049d858c20413cbdff6e610c4d",
@ -43,6 +45,7 @@ provider "registry.terraform.io/hashicorp/local" {
version = "2.2.3"
hashes = [
"h1:FvRIEgCmAezgZUqb2F+PZ9WnSSnR5zbEM2ZI+GLmbMk=",
"h1:aWp5iSUxBGgPv1UnV5yag9Pb0N+U1I0sZb38AXBFO8A=",
"zh:04f0978bb3e052707b8e82e46780c371ac1c66b689b4a23bbc2f58865ab7d5c0",
"zh:6484f1b3e9e3771eb7cc8e8bab8b35f939a55d550b3f4fb2ab141a24269ee6aa",
"zh:78a56d59a013cb0f7eb1c92815d6eb5cf07f8b5f0ae20b96d049e73db915b238",
@ -61,6 +64,7 @@ provider "registry.terraform.io/hashicorp/local" {
provider "registry.terraform.io/hashicorp/random" {
version = "3.3.2"
hashes = [
"h1:H5V+7iXol/EHB2+BUMzGlpIiCOdV74H8YjzCxnSAWcg=",
"h1:YChjos7Hrvr2KgTc9GzQ+de/QE2VLAeRJgxFemnCltU=",
"zh:038293aebfede983e45ee55c328e3fde82ae2e5719c9bd233c324cfacc437f9c",
"zh:07eaeab03a723d83ac1cc218f3a59fceb7bbf301b38e89a26807d1c93c81cef8",

Просмотреть файл

@ -1,4 +1,4 @@
terraform {
backend "azurerm" {
}
}
# terraform {
# backend "azurerm" {
# }
# }

Просмотреть файл

@ -520,38 +520,28 @@ resource "azurerm_private_endpoint" "keyvault" {
##############################################
# AZURE DATABASE FOR MYSQL
##############################################
resource "azurerm_mysql_server" "redcap" {
name = local.mysql_name
resource_group_name = azurerm_resource_group.redcap.name
location = azurerm_resource_group.redcap.location
tags = var.tags
administrator_login = var.administratorLogin
administrator_login_password = random_password.redcap.result
sku_name = local.mysql_sku
storage_mb = var.databaseSkuSizeMB
version = var.mysqlVersion
auto_grow_enabled = true
backup_retention_days = 30
geo_redundant_backup_enabled = true
infrastructure_encryption_enabled = false
public_network_access_enabled = true
ssl_enforcement_enabled = false
#ssl_minimal_tls_version_enforced = "TLS1_2"
# threat_detection_policy {
# enabled = true
# email_account_admins = true
# email_addresses = [var.administrator_email]
# retention_days = 30
# storage_account_access_key = azurerm_storage_account.redcap.primary_access_key
# storage_endpoint = azurerm_storage_account.redcap.primary_blob_endpoint
# }
resource "azurerm_mysql_flexible_server" "redcap" {
name = local.mysql_name
resource_group_name = azurerm_resource_group.redcap.name
location = azurerm_resource_group.redcap.location
tags = var.tags
administrator_login = var.administratorLogin
administrator_password = random_password.redcap.result
sku_name = local.mysql_sku
storage {
size_gb = var.databaseStorageSizeGB
auto_grow_enabled = true
iops = 360
}
version = var.mysqlVersion
backup_retention_days = 30
geo_redundant_backup_enabled = true
}
resource "azurerm_mysql_virtual_network_rule" "compute" {
name = "${azurerm_subnet.redcap["ComputeSubnet"].name}Rule"
resource_group_name = azurerm_resource_group.redcap.name
server_name = azurerm_mysql_server.redcap.name
server_name = azurerm_mysql_flexible_server.redcap.name
subnet_id = azurerm_subnet.redcap["ComputeSubnet"].id
depends_on = [
@ -562,7 +552,7 @@ resource "azurerm_mysql_virtual_network_rule" "compute" {
resource "azurerm_mysql_virtual_network_rule" "integration" {
name = "${azurerm_subnet.redcap["IntegrationSubnet"].name}Rule"
resource_group_name = azurerm_resource_group.redcap.name
server_name = azurerm_mysql_server.redcap.name
server_name = azurerm_mysql_flexible_server.redcap.name
subnet_id = azurerm_subnet.redcap["IntegrationSubnet"].id
depends_on = [
@ -573,7 +563,7 @@ resource "azurerm_mysql_virtual_network_rule" "integration" {
resource "azurerm_mysql_virtual_network_rule" "privatelink" {
name = "${azurerm_subnet.redcap["PrivateLinkSubnet"].name}Rule"
resource_group_name = azurerm_resource_group.redcap.name
server_name = azurerm_mysql_server.redcap.name
server_name = azurerm_mysql_flexible_server.redcap.name
subnet_id = azurerm_subnet.redcap["PrivateLinkSubnet"].id
depends_on = [
@ -581,10 +571,10 @@ resource "azurerm_mysql_virtual_network_rule" "privatelink" {
]
}
resource "azurerm_mysql_database" "redcap" {
resource "azurerm_mysql_flexible_database" "redcap" {
name = "${var.siteName}_db"
resource_group_name = azurerm_resource_group.redcap.name
server_name = azurerm_mysql_server.redcap.name
server_name = azurerm_mysql_flexible_server.redcap.name
charset = "utf8"
collation = "utf8_unicode_ci"
}
@ -605,7 +595,7 @@ resource "azurerm_private_endpoint" "mysql" {
private_service_connection {
name = "${local.mysql_name}-pe"
private_connection_resource_id = azurerm_mysql_server.redcap.id
private_connection_resource_id = azurerm_mysql_flexible_server.redcap.id
is_manual_connection = false
subresource_names = [
"mysqlServer"
@ -732,6 +722,7 @@ resource "azurerm_app_service" "redcap" {
"DBName" = "${var.siteName}_db",
"DBUserName" = "${var.administratorLogin}@${local.mysql_name}",
"DBPassword" = "@Microsoft.KeyVault(VaultName=${azurerm_key_vault.redcap.name};SecretName=${azurerm_key_vault_secret.mysql.name})",
"DBSslCa" = "/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem",
"PHP_INI_SCAN_DIR" = "/usr/local/etc/php/conf.d:/home/site",
"from_email_address" = var.administrator_email,
"smtp_fqdn_name" = "NOT_USED",

Просмотреть файл

@ -218,9 +218,9 @@ variable "skuCapacity" {
default = 1
}
variable "databaseSkuSizeMB" {
variable "databaseStorageSizeGB" {
type = number
default = 5120
default = 32
description = "Azure database for MySQL sku Size."
}