diff --git a/docs/examples/101/webapp-managed-mysql/main.bicep b/docs/examples/101/webapp-managed-mysql/main.bicep new file mode 100644 index 00000000000..3588cf364c7 --- /dev/null +++ b/docs/examples/101/webapp-managed-mysql/main.bicep @@ -0,0 +1,120 @@ +param websiteName string +param dbAdminLogin string +param dbAdminPassword string { + secure: true + minLength: 8 + maxLength: 128 +} +param dbSkuCapacity int { + default: 2 + allowed: [ + 2 + 4 + 8 + 16 + 32 + ] +} +param dbSkuName string { + default: 'GP_Gen5_2' + allowed: [ + 'GP_Gen5_2' + 'GP_Gen5_4' + 'GP_Gen5_8' + 'GP_Gen5_16' + 'GP_Gen5_32' + 'MO_Gen5_2' + 'MO_Gen5_4' + 'MO_Gen5_8' + 'MO_Gen5_16' + 'MO_Gen5_32' + ] +} +param dbSkuSizeInMB int { + default: 51200 + allowed: [ + 51200 + 102400 + ] +} +param dbSkuTier string { + default: 'GeneralPurpose' + allowed: [ + 'GeneralPurpose' + 'MemoryOptimized' + ] +} +param dbSkuFamily string = 'Gen5' +param mySQLVersion string { + allowed: [ + '5.6' + '5.7' + ] +} +param location string = resourceGroup().location + +var dbName = '${websiteName}-db' +var dbServerName = '${websiteName}-server' +var serverFarmName = '${websiteName}-serviceplan' + +resource serverFarm 'Microsoft.Web/serverfarms@2020-06-01' = { + name: serverFarmName + location: location + sku: { + tier: 'Standard' + name: 'S1' + } +} +resource website 'Microsoft.Web/sites@2020-06-01' = { + name: websiteName + location: location + properties: { + serverFarmId: serverFarm.id + } +} +resource connectionString 'Microsoft.Web/sites/config@2020-06-01' = { + name: '${website.name}/connectionString' + properties: { + defaultConnection: { + value: 'Database=${dbName};Data Source=${dbServer.properties.fullyQualifiedDomainName};User Id=${dbAdminLogin}@${dbServer.name};Password=${dbAdminPassword}' + type: 'MySql' + } + } +} +resource dbServer 'Microsoft.DBForMySQL/servers@2017-12-01-preview' = { + name: dbServerName + location: location + sku: { + name: dbSkuName + tier: dbSkuTier + capacity: dbSkuCapacity + size: string(dbSkuSizeInMB) + family: dbSkuFamily + } + properties: { + createMode: 'Default' + version: mySQLVersion + administratorLogin: dbAdminLogin + administratorLoginPassword: dbAdminPassword + storageProfile: { + storageMB: dbSkuSizeInMB + backupRetentionDays: 7 + geoRedundantBackup: 'Disabled' + } + sslEnforcement: 'Disabled' + } +} +resource firewallRules 'Microsoft.DBForMySQL/servers/firewallRules@2017-12-01-preview' = { + name: '${dbServer.name}/allowAzureIPs' + properties: { + startIpAddress: '0.0.0.0' + endIpAddress: '0.0.0.0' + } +} +resource database 'Microsoft.DBForMySQL/servers/databases@2017-12-01-preview' = { + name: '${dbServer.name}/${dbName}' + properties: { + charset: 'utf8' + collation: 'utf8_general_ci' + } +} diff --git a/docs/examples/101/webapp-managed-mysql/main.json b/docs/examples/101/webapp-managed-mysql/main.json new file mode 100644 index 00000000000..a9ef3e7d7ae --- /dev/null +++ b/docs/examples/101/webapp-managed-mysql/main.json @@ -0,0 +1,169 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "websiteName": { + "type": "string" + }, + "dbAdminLogin": { + "type": "string" + }, + "dbAdminPassword": { + "type": "secureString", + "minLength": 8, + "maxLength": 128 + }, + "dbSkuCapacity": { + "type": "int", + "defaultValue": 2, + "allowedValues": [ + 2, + 4, + 8, + 16, + 32 + ] + }, + "dbSkuName": { + "type": "string", + "defaultValue": "GP_Gen5_2", + "allowedValues": [ + "GP_Gen5_2", + "GP_Gen5_4", + "GP_Gen5_8", + "GP_Gen5_16", + "GP_Gen5_32", + "MO_Gen5_2", + "MO_Gen5_4", + "MO_Gen5_8", + "MO_Gen5_16", + "MO_Gen5_32" + ] + }, + "dbSkuSizeInMB": { + "type": "int", + "defaultValue": 51200, + "allowedValues": [ + 51200, + 102400 + ] + }, + "dbSkuTier": { + "type": "string", + "defaultValue": "GeneralPurpose", + "allowedValues": [ + "GeneralPurpose", + "MemoryOptimized" + ] + }, + "dbSkuFamily": { + "type": "string", + "defaultValue": "Gen5" + }, + "mySQLVersion": { + "type": "string", + "allowedValues": [ + "5.6", + "5.7" + ] + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]" + } + }, + "functions": [], + "variables": { + "dbName": "[format('{0}-db', parameters('websiteName'))]", + "dbServerName": "[format('{0}-server', parameters('websiteName'))]", + "serverFarmName": "[format('{0}-serviceplan', parameters('websiteName'))]" + }, + "resources": [ + { + "type": "Microsoft.Web/serverfarms", + "apiVersion": "2020-06-01", + "name": "[variables('serverFarmName')]", + "location": "[parameters('location')]", + "sku": { + "tier": "Standard", + "name": "S1" + } + }, + { + "type": "Microsoft.Web/sites", + "apiVersion": "2020-06-01", + "name": "[parameters('websiteName')]", + "location": "[parameters('location')]", + "properties": { + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]" + ] + }, + { + "type": "Microsoft.Web/sites/config", + "apiVersion": "2020-06-01", + "name": "[format('{0}/connectionString', parameters('websiteName'))]", + "properties": { + "defaultConnection": { + "value": "[format('Database={0};Data Source={1};User Id={2}@{3};Password={4}', variables('dbName'), reference(resourceId('Microsoft.DBForMySQL/servers', variables('dbServerName'))).fullyQualifiedDomainName, parameters('dbAdminLogin'), variables('dbServerName'), parameters('dbAdminPassword'))]", + "type": "MySql" + } + }, + "dependsOn": [ + "[resourceId('Microsoft.DBForMySQL/servers', variables('dbServerName'))]", + "[resourceId('Microsoft.Web/sites', parameters('websiteName'))]" + ] + }, + { + "type": "Microsoft.DBForMySQL/servers", + "apiVersion": "2017-12-01-preview", + "name": "[variables('dbServerName')]", + "location": "[parameters('location')]", + "sku": { + "name": "[parameters('dbSkuName')]", + "tier": "[parameters('dbSkuTier')]", + "capacity": "[parameters('dbSkuCapacity')]", + "size": "[string(parameters('dbSkuSizeInMB'))]", + "family": "[parameters('dbSkuFamily')]" + }, + "properties": { + "createMode": "Default", + "version": "[parameters('mySQLVersion')]", + "administratorLogin": "[parameters('dbAdminLogin')]", + "administratorLoginPassword": "[parameters('dbAdminPassword')]", + "storageProfile": { + "storageMB": "[parameters('dbSkuSizeInMB')]", + "backupRetentionDays": 7, + "geoRedundantBackup": "Disabled" + }, + "sslEnforcement": "Disabled" + } + }, + { + "type": "Microsoft.DBForMySQL/servers/firewallRules", + "apiVersion": "2017-12-01-preview", + "name": "[format('{0}/allowAzureIPs', variables('dbServerName'))]", + "properties": { + "startIpAddress": "0.0.0.0", + "endIpAddress": "0.0.0.0" + }, + "dependsOn": [ + "[resourceId('Microsoft.DBForMySQL/servers', variables('dbServerName'))]" + ] + }, + { + "type": "Microsoft.DBForMySQL/servers/databases", + "apiVersion": "2017-12-01-preview", + "name": "[format('{0}/{1}', variables('dbServerName'), variables('dbName'))]", + "properties": { + "charset": "utf8", + "collation": "utf8_general_ci" + }, + "dependsOn": [ + "[resourceId('Microsoft.DBForMySQL/servers', variables('dbServerName'))]" + ] + } + ] +} \ No newline at end of file diff --git a/docs/examples/index.json b/docs/examples/index.json index ef631042a24..8b5256b50e4 100644 --- a/docs/examples/index.json +++ b/docs/examples/index.json @@ -247,6 +247,10 @@ "filePath": "101/web-app-windows/main.bicep", "description": "101/web-app-windows" }, + { + "filePath": "101/webapp-managed-mysql/main.bicep", + "description": "101/webapp-managed-mysql" + }, { "filePath": "101/webapp-privateendpoint-vnet-injection/main.bicep", "description": "101/webapp-privateendpoint-vnet-injection"