azure-redcap-paas/toClean/azuredeploy.bicep

335 строки
8.3 KiB
Bicep
Исходник Обычный вид История

2023-02-05 09:57:13 +03:00
param location string = resourceGroup().location
@description('Name of azure web app')
param siteName string
@description('Stack settings')
param linuxFxVersion string = 'php|7.4'
@description('Database administrator login name')
@minLength(1)
param administratorLogin string = 'redcap_app'
@description('Database administrator password')
@minLength(8)
@secure()
param administratorLoginPassword string
@description('REDCap zip file URI.')
param redcapAppZip string = ''
@description('REDCap Community site username for downloading the REDCap zip file.')
param redcapCommunityUsername string
@description('REDCap Community site password for downloading the REDCap zip file.')
@secure()
param redcapCommunityPassword string
@description('REDCap zip file version to be downloaded from the REDCap Community site.')
param redcapAppZipVersion string = 'latest'
@description('Email address configured as the sending address in REDCap')
param fromEmailAddress string
@description('Fully-qualified domain name of your SMTP relay endpoint')
param smtpFQDN string
@description('Login name for your SMTP relay')
param smtpUser string
@description('Login password for your SMTP relay')
@secure()
param smtpPassword string
@description('Port for your SMTP relay')
param smtpPort string = '587'
@description('Describes plan\'s pricing tier and capacity - this can be changed after deployment. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/')
@allowed([
'F1'
'D1'
'B1'
'B2'
'B3'
'S1'
'S2'
'S3'
'P1v2'
'P2v2'
'P3v2'
'P1v3'
'P2v3'
'P3v3'
])
param skuName string = 'S1'
@description('Describes plan\'s instance count (how many distinct web servers will be deployed in the farm) - this can be changed after deployment')
@minValue(1)
param skuCapacity int = 1
2023-02-05 09:57:13 +03:00
@description('Initial MySQL database storage size in GB ')
param databaseStorageSizeGB int = 32
2023-02-05 09:57:13 +03:00
@description('Initial MySQL databse storage IOPS')
param databaseStorageIops int = 396
@allowed([
2023-02-05 09:57:13 +03:00
'Enabled'
'Disabled'
])
2023-02-05 09:57:13 +03:00
param databaseStorageAutoGrow string = 'Enabled'
@allowed([
2023-02-05 09:57:13 +03:00
'Enabled'
'Disabled'
])
2023-02-05 09:57:13 +03:00
param databseStorageAutoIoScaling string = 'Enabled'
@description('MySQL version')
@allowed([
'5.6'
'5.7'
])
param mysqlVersion string = '5.7'
@description('The default selected is \'Locally Redundant Storage\' (3 copies in one region). See https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy for more information.')
@allowed([
'Standard_LRS'
'Standard_ZRS'
'Standard_GRS'
'Standard_RAGRS'
'Premium_LRS'
])
param storageType string = 'Standard_LRS'
@description('Name of the container used to store backing files in the new storage account. This container is created automatically during deployment.')
param storageContainerName string = 'redcap'
@description('The path to the deployment source files on GitHub')
2022-06-29 19:28:10 +03:00
param repoURL string = 'https://github.com/microsoft/azure-redcap-paas.git'
@description('The main branch of the application repo')
2022-06-29 19:28:10 +03:00
param branch string = 'main'
2023-02-05 09:57:13 +03:00
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' = {
2023-02-05 09:57:13 +03:00
name: uniqueStorageName
location: location
sku: {
name: storageType
}
tags: {
displayName: 'BackingStorage'
}
kind: 'Storage'
dependsOn: []
}
resource blobServices 'Microsoft.Storage/storageAccounts/blobServices@2021-09-01' = {
name: 'default'
parent: storageName
}
resource storageContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-09-01' = {
name: storageContainerName
parent: blobServices
}
resource hostingPlanName 'Microsoft.Web/serverfarms@2016-09-01' = {
2023-02-05 09:57:13 +03:00
name: hostingPlanNameCleaned
location: location
tags: {
displayName: 'HostingPlan'
}
sku: {
name: skuName
capacity: skuCapacity
}
kind: 'linux'
properties: {
2023-02-05 09:57:13 +03:00
name: hostingPlanNameCleaned
reserved: true
}
}
resource webSiteName 'Microsoft.Web/sites@2016-08-01' = {
2023-02-05 09:57:13 +03:00
name: uniqueWebSiteName
location: location
tags: {
displayName: 'WebApp'
}
properties: {
2023-02-05 09:57:13 +03:00
name: uniqueWebSiteName
serverFarmId: hostingPlanNameCleaned
siteConfig: {
linuxFxVersion: linuxFxVersion
alwaysOn: true
appCommandLine: '/home/startup.sh'
appSettings: [
{
name: 'StorageContainerName'
value: storageContainerName
}
{
name: 'StorageAccount'
2023-02-05 09:57:13 +03:00
value: uniqueStorageName
}
{
name: 'StorageKey'
value: concat(listKeys(storageAccountId, '2015-05-01-preview').key1)
}
{
name: 'redcapAppZip'
value: redcapAppZip
}
{
name: 'redcapCommunityUsername'
value: redcapCommunityUsername
}
{
name: 'redcapCommunityPassword'
value: redcapCommunityPassword
}
{
name: 'redcapAppZipVersion'
value: redcapAppZipVersion
}
{
name: 'DBHostName'
2023-02-05 09:57:13 +03:00
value: '${uniqueServerName}.mysql.database.azure.com'
}
{
name: 'DBName'
value: databaseName
}
{
name: 'DBUserName'
2023-02-05 09:57:13 +03:00
value: administratorLogin
}
{
name: 'DBPassword'
value: administratorLoginPassword
}
2023-02-05 09:57:13 +03:00
{
name: 'DBSslCa'
value: '/home/site/wwwroot/DigiCertGlobalRootCA.crt.pem'
}
{
name: 'PHP_INI_SCAN_DIR'
value: '/usr/local/etc/php/conf.d:/home/site'
}
{
name: 'from_email_address'
value: fromEmailAddress
}
{
name: 'smtp_fqdn_name'
value: smtpFQDN
}
{
name: 'smtp_port'
value: smtpPort
}
{
name: 'smtp_user_name'
value: smtpUser
}
{
name: 'smtp_password'
value: smtpPassword
}
{
name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'
value: '1'
}
]
}
}
dependsOn: [
hostingPlanName
storageName
]
}
resource webSiteName_web 'Microsoft.Web/sites/sourcecontrols@2015-08-01' = {
parent: webSiteName
name: 'web'
2023-02-05 09:57:13 +03:00
location: location
tags: {
displayName: 'CodeDeploy'
}
properties: {
repoUrl: repoURL
branch: branch
isManualIntegration: true
}
dependsOn: [
serverName
]
}
2023-02-05 09:57:13 +03:00
resource serverName 'Microsoft.DBforMySQL/flexibleServers@2021-12-01-preview' = {
location: location
name: uniqueServerName
tags: {
displayName: 'MySQLAzure'
}
properties: {
version: mysqlVersion
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
2023-02-05 09:57:13 +03:00
storage: {
storageSizeGB: databaseStorageSizeGB
iops: databaseStorageIops
autoGrow: databaseStorageAutoGrow
autoIoScaling: databseStorageAutoIoScaling
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
2023-02-05 09:57:13 +03:00
highAvailability: {
mode: 'Disabled'
}
replicationRole: 'None'
}
sku: {
2023-02-05 09:57:13 +03:00
name: 'Standard_B1ms'
tier: 'Burstable'
}
}
2023-02-05 09:57:13 +03:00
resource serverName_AllowAzureIPs 'Microsoft.DBforMySQL/flexibleServers/firewallRules@2021-12-01-preview' = {
parent: serverName
name: 'AllowAzureIPs'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
}
dependsOn: [
serverName_databaseName
]
}
2023-02-05 09:57:13 +03:00
resource serverName_databaseName 'Microsoft.DBforMySQL/flexibleServers/databases@2021-12-01-preview' = {
parent: serverName
2023-02-05 09:57:13 +03:00
name: databaseName
properties: {
charset: 'utf8'
collation: 'utf8_general_ci'
}
}
2023-02-05 09:57:13 +03:00
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