From f07bc0f02039e1e532df3646dcf078bc9d308cb4 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Wed, 15 Sep 2021 13:50:58 +0800 Subject: [PATCH 1/5] On branch galia-3rddb: support 3rd data source Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/createUiDefinition.json modified: weblogic-azure-aks/src/main/arm/scripts/buildWLSDockerImage.sh modified: weblogic-azure-aks/src/main/arm/scripts/createVMAndBuildImage.sh modified: weblogic-azure-aks/src/main/arm/scripts/dbUtility.sh modified: weblogic-azure-aks/src/main/arm/scripts/genDatasourceModel.sh modified: weblogic-azure-aks/src/main/arm/scripts/genImageModel.sh modified: weblogic-azure-aks/src/main/bicep/mainTemplate.bicep modified: weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep modified: weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-datasource-connection.bicep modified: weblogic-azure-aks/src/main/bicep/modules/_setupDBConnection.bicep modified: weblogic-azure-aks/src/main/bicep/modules/setupDBConnection.bicep modified: weblogic-azure-aks/src/main/bicep/modules/setupWebLogicCluster.bicep --- .../src/main/arm/createUiDefinition.json | 117 ++++++++++++++++-- .../main/arm/scripts/buildWLSDockerImage.sh | 37 +++++- .../main/arm/scripts/createVMAndBuildImage.sh | 15 ++- .../src/main/arm/scripts/dbUtility.sh | 4 + .../main/arm/scripts/genDatasourceModel.sh | 2 +- .../src/main/arm/scripts/genImageModel.sh | 2 +- .../src/main/bicep/mainTemplate.bicep | 14 +++ .../_ds-create-wls-cluster.bicep | 7 ++ .../_ds-datasource-connection.bicep | 17 +++ .../bicep/modules/_setupDBConnection.bicep | 9 ++ .../bicep/modules/setupDBConnection.bicep | 4 + .../bicep/modules/setupWebLogicCluster.bicep | 2 + 12 files changed, 216 insertions(+), 14 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/createUiDefinition.json b/weblogic-azure-aks/src/main/arm/createUiDefinition.json index f5ded01f9..2fc7cb742 100644 --- a/weblogic-azure-aks/src/main/arm/createUiDefinition.json +++ b/weblogic-azure-aks/src/main/arm/createUiDefinition.json @@ -1672,6 +1672,10 @@ { "label": "Azure SQL", "value": "sqlserver" + }, + { + "label": "Others", + "value": "otherdb" } ], "required": true @@ -1685,9 +1689,9 @@ "toolTip": "The JNDI name for the database JDBC connection", "defaultValue": "", "constraints": { - "required": "[bool(steps('section_database').enableDB)]", - "regex": "^[a-zA-Z0-9./_-]{1,30}$", - "validationMessage": "The value must be 1-30 characters long and must only contain letters, numbers, hyphens (-), underscores (_), periods (.) and slashes (/)." + "required": true, + "regex": "^[a-z0-9A-Z/]{1,30}$", + "validationMessage": "The value must be 1-30 characters long and must only contain letters, numbers, and slashes (/)." }, "visible": true }, @@ -1698,10 +1702,62 @@ "toolTip": "The JDBC connection string for the database", "defaultValue": "", "constraints": { - "required": "[bool(steps('section_database').enableDB)]", + "required": true, "regex": "[concat('^jdbc:', coalesce(steps('section_database').databaseConnectionInfo.databaseType, ''), '.*$')]", "validationMessage": "A valid JDBC URL for the chosen database type must be provided" }, + "visible": "[and(bool(steps('section_database').enableDB), not(equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb')))]" + }, + { + "name": "dsConnectionURL2", + "type": "Microsoft.Common.TextBox", + "label": "DataSource Connection String", + "toolTip": "The JDBC connection string for the database", + "defaultValue": "", + "constraints": { + "required": true, + "regex": "^jdbc:.*$", + "validationMessage": "A valid JDBC URL for the chosen database type must be provided" + }, + "visible": "[and(bool(steps('section_database').enableDB), equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb'))]" + }, + { + "name": "dbGlobalTranPro", + "type": "Microsoft.Common.DropDown", + "label": "Global transactions protocol", + "defaultValue": "EmulateTwoPhaseCommit", + "multiLine": true, + "toolTip": "Determines the transaction protocol (global transaction processing behavior) for the data source.", + "constraints": { + "allowedValues": [ + { + "label": "TwoPhaseCommit", + "description": "Standard XA transaction processing. Requires an XA driver.", + "value": "TwoPhaseCommit" + }, + { + "label": "LoggingLastResource", + "description": "A performance enhancement for one non-XA resource.", + "value": "LoggingLastResource" + }, + { + "label": "EmulateTwoPhaseCommit", + "description": "Enables one non-XA resource to participate in a global transaction, but has some risk to data.", + "value": "EmulateTwoPhaseCommit" + }, + { + "label": "OnePhaseCommit", + "description": "One-phase XA transaction processing using a non-XA driver. This is the default setting.", + "value": "OnePhaseCommit" + }, + { + "label": "None", + "description": "Support for local transactions only.", + "value": "None" + } + ], + "required": true + }, "visible": true }, { @@ -1711,8 +1767,8 @@ "toolTip": "Use only letters and numbers", "defaultValue": "", "constraints": { - "required": "[bool(steps('section_database').enableDB)]", - "regex": "^(?=.{1,128}$)[a-zA-Z](?!.*--)(?!.*@@)(?!.*-@)(?!.*@-)[a-zA-Z0-9-@]*[a-zA-Z0-9]$", + "required": true, + "regex": "^(?!\\-)([a-z0-9A-Z@\\-]{1,128})([^\\-])$", "validationMessage": "The value must be 1-128 characters long and must only contain letters, numbers, hyphen(-) and the at sign, no hyphen allowed at the beginning and the end of database username." }, "visible": true @@ -1726,7 +1782,7 @@ }, "toolTip": "Database Password", "constraints": { - "required": "[bool(steps('section_database').enableDB)]", + "required": true, "regex": "^((?=.*[0-9])(?=.*[a-zA-Z!@#$%^&*])).{5,128}$", "validationMessage": "The password must be between 5 and 128 characters long and have at least one number." }, @@ -1734,6 +1790,47 @@ "hideConfirmation": false }, "visible": true + }, + { + "name": "dbDriverLibraries", + "type": "Microsoft.Common.FileUpload", + "label": "DataSource driver (.jar)", + "toolTip": "The datasource driver jar package for the specified database.", + "constraints": { + "required": true, + "accept": ".jar" + }, + "options": { + "multiple": true, + "uploadMode": "url", + "openMode": "binary" + }, + "visible": "[and(bool(steps('section_database').enableDB), equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb'))]" + }, + { + "name": "dbDriverName", + "type": "Microsoft.Common.TextBox", + "label": "DataSource driver name", + "toolTip": "The driver name for the database", + "placeholder": "com.informix.jdbc.IfxDriver", + "constraints": { + "required": true, + "regex": "^[a-zA-Z_][a-zA-Z0-9_]+(\\.[a-zA-Z_][a-zA-Z0-9_]+){1,50}$", + "validationMessage": "A valid driver name for the chosen database type must be provided" + }, + "visible": "[and(bool(steps('section_database').enableDB), equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb'))]" + }, + { + "name": "dbTestTableName", + "type": "Microsoft.Common.TextBox", + "label": "Test table name", + "toolTip": "The name of the database table to use when testing physical database connections. ", + "constraints": { + "required": true, + "regex": "^.*$", + "validationMessage": "A test table name for the chosen database type must be provided" + }, + "visible": "[and(bool(steps('section_database').enableDB), equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb'))]" } ], "visible": "[bool(steps('section_database').enableDB)]" @@ -1758,7 +1855,11 @@ "createACR": "[bool(steps('section_aks').imageInfo.oracleCreateACR)]", "createAKSCluster": "[bool(steps('section_aks').clusterInfo.createAKSCluster)]", "createDNSZone": "[not(bool(steps('section_dnsConfiguration').bringDNSZone))]", + "dbDriverLibrariesUrls": "[steps('section_database').databaseConnectionInfo.dbDriverLibraries]", + "dbDriverName": "[steps('section_database').databaseConnectionInfo.dbDriverName]", + "dbGlobalTranPro": "[steps('section_database').databaseConnectionInfo.dbGlobalTranPro]", "dbPassword": "[steps('section_database').databaseConnectionInfo.dbPassword]", + "dbTestTableName": "[steps('section_database').databaseConnectionInfo.dbTestTableName]", "dbUser": "[steps('section_database').databaseConnectionInfo.dbUser]", "databaseType": "[steps('section_database').databaseConnectionInfo.databaseType]", "dnszoneAdminConsoleLabel": "[steps('section_dnsConfiguration').dnszoneAdminConsoleLabel]", @@ -1767,7 +1868,7 @@ "dnszoneClusterT3ChannelLabel": "[steps('section_dnsConfiguration').dnszoneClusterT3ChannelLabel]", "dnszoneName": "[steps('section_dnsConfiguration').dnszoneName]", "dnszoneRGName": "[steps('section_dnsConfiguration').dnsZoneResourceGroup]", - "dsConnectionURL": "[steps('section_database').databaseConnectionInfo.dsConnectionURL]", + "dsConnectionURL": "[coalesce(steps('section_database').databaseConnectionInfo.dsConnectionURL, steps('section_database').databaseConnectionInfo.dsConnectionURL2, 'null')]", "enableAppGWIngress": "[steps('section_appGateway').appgwIngress.enableAppGateway]", "enableAzureMonitoring": "[bool(steps('section_aks').clusterInfo.enableAzureMonitoring)]", "enableAzureFileShare": "[bool(steps('section_aks').clusterInfo.enableAzureFileShare)]", diff --git a/weblogic-azure-aks/src/main/arm/scripts/buildWLSDockerImage.sh b/weblogic-azure-aks/src/main/arm/scripts/buildWLSDockerImage.sh index fa561e43e..5eb663b1a 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/buildWLSDockerImage.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/buildWLSDockerImage.sh @@ -15,7 +15,7 @@ function read_sensitive_parameters_from_stdin() { #Function to display usage message function usage() { - echo " ./buildWLSDockerImage.sh ./buildWLSDockerImage.sh " + echo " | ./buildWLSDockerImage.sh " if [ $1 -eq 1 ]; then exit 1 fi @@ -95,6 +95,11 @@ function validate_inputs() { echo_stderr "enableClusterT3Tunneling is required. " usage 1 fi + + if [ -z "${dbDriversUrls}" ]; then + echo_stderr "dbDriversUrls is required. " + usage 1 + fi } function initialize() { @@ -169,6 +174,32 @@ function install_utilities() { validate_status "Install mssql driver." } +function install_db_drivers() { + if [ "${dbDriversUrls}" == "[]" ] || [ -z "${dbDriversUrls}" ]; then + return + fi + + local dbDriversUrls=$(echo "${dbDriversUrls:1:${#dbDriversUrls}-2}") + local dbDriversUrlsArray=$(echo $dbDriversUrls | tr "," "\n") + + for item in $dbDriversUrlsArray; do + echo ${item} + # e.g. https://wlsaksapp.blob.core.windows.net/japps/mariadb-java-client-2.7.4.jar?sp=r&se=2021-04-29T15:12:38Z&sv=2020-02-10&sr=b&sig=7grL4qP%2BcJ%2BLfDJgHXiDeQ2ZvlWosRLRQ1ciLk0Kl7M%3D + local urlWithoutQueryString="${item%\?*}" + echo $urlWithoutQueryString + local fileName="${urlWithoutQueryString##*/}" + echo $fileName + + curl -m ${curlMaxTime} -fL "$item" -o ${scriptDir}/model-images/wlsdeploy/domainLibraries/${fileName} + if [ $? -ne 0 ];then + echo "Failed to download $item" + exit 1 + fi + + dbDriverPaths="${dbDriverPaths},'wlsdeploy/domainLibraries/${fileName}'" + done +} + # Login in OCR # Pull weblogic image function get_wls_image_from_ocr() { @@ -288,8 +319,10 @@ export enableSSL=$8 export enableAdminT3Tunneling=$9 export enableClusterT3Tunneling=${10} export useOracleImage=${11} +export dbDriversUrls=${12} export acrImagePath="$azureACRServer/aks-wls-images:${imageTag}" +export dbDriverPaths="" export ocrLoginServer="container-registry.oracle.com" export wdtDownloadURL="https://github.com/oracle/weblogic-deploy-tooling/releases/download/release-1.9.17/weblogic-deploy.zip" export witDownloadURL="https://github.com/oracle/weblogic-image-tool/releases/download/release-1.9.16/imagetool.zip" @@ -304,6 +337,8 @@ initialize install_utilities +install_db_drivers + if [[ "${useOracleImage,,}" == "${constTrue}" ]]; then get_wls_image_from_ocr else diff --git a/weblogic-azure-aks/src/main/arm/scripts/createVMAndBuildImage.sh b/weblogic-azure-aks/src/main/arm/scripts/createVMAndBuildImage.sh index f6d61c1cf..d605a0cd1 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/createVMAndBuildImage.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/createVMAndBuildImage.sh @@ -6,6 +6,13 @@ function read_sensitive_parameters_from_stdin() { read azureACRPassword ocrSSOPSW } +function initialize() { + # initialize URL_3RD_DATASOURCE + if [ -z "${URL_3RD_DATASOURCE}" ];then + URL_3RD_DATASOURCE="[]" + fi +} + function cleanup_vm() { #Remove VM resources az extension add --name resource-graph @@ -89,11 +96,11 @@ function build_docker_image() { if [[ "${useOracleImage,,}" == "${constTrue}" ]]; then wlsImagePath="${ocrLoginServer}/middleware/weblogic:${wlsImageTag}" else - wlsImagePath="${userProvidedImagePath}" + wlsImagePath="${userProvidedImagePath}" fi echo "wlsImagePath: ${wlsImagePath}" - + URL_3RD_DATASOURCE=$(echo $URL_3RD_DATASOURCE | tr -d "\"") # remove " from the string az vm extension set --name CustomScript \ --extension-instance-name wls-image-script \ --resource-group ${currentResourceGroup} \ @@ -101,7 +108,7 @@ function build_docker_image() { --publisher Microsoft.Azure.Extensions \ --version 2.0 \ --settings "{ \"fileUris\": [\"${scriptURL}model.properties\",\"${scriptURL}genImageModel.sh\",\"${scriptURL}buildWLSDockerImage.sh\",\"${scriptURL}common.sh\"]}" \ - --protected-settings "{\"commandToExecute\":\"echo ${azureACRPassword} ${ocrSSOPSW} | bash buildWLSDockerImage.sh ${wlsImagePath} ${azureACRServer} ${azureACRUserName} ${newImageTag} \\\"${appPackageUrls}\\\" ${ocrSSOUser} ${wlsClusterSize} ${enableCustomSSL} ${enableAdminT3Tunneling} ${enableClusterT3Tunneling} ${useOracleImage} \"}" + --protected-settings "{\"commandToExecute\":\"echo ${azureACRPassword} ${ocrSSOPSW} | bash buildWLSDockerImage.sh ${wlsImagePath} ${azureACRServer} ${azureACRUserName} ${newImageTag} \\\"${appPackageUrls}\\\" ${ocrSSOUser} ${wlsClusterSize} ${enableCustomSSL} ${enableAdminT3Tunneling} ${enableClusterT3Tunneling} ${useOracleImage} \\\"${URL_3RD_DATASOURCE}\\\" \"}" cleanup_vm } @@ -132,6 +139,8 @@ export userProvidedImagePath=${14} read_sensitive_parameters_from_stdin +initialize + build_docker_image diff --git a/weblogic-azure-aks/src/main/arm/scripts/dbUtility.sh b/weblogic-azure-aks/src/main/arm/scripts/dbUtility.sh index 9bc9c86ff..162a1c4fc 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/dbUtility.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/dbUtility.sh @@ -17,6 +17,9 @@ function generate_ds_model() { elif [[ "${databaseType}" == "${dbTypeSQLServer}" ]]; then databaseDriver=${driverSQLServer} databaseTestTableName=${testTableSQLServer} + elif [[ "${databaseType}" == "${dbTypeOthers}" ]]; then + databaseDriver=${DB_DRIVER_NAME} + databaseTestTableName=${TEST_TABLE_NAME} fi echo "generate data source model file" @@ -152,6 +155,7 @@ export clusterName="cluster-1" export dbTypeOracle="oracle" export dbTypePostgre="postgresql" export dbTypeSQLServer="sqlserver" +export dbTypeOthers="otherdb" export driverOracle="oracle.jdbc.OracleDriver" export driverPostgre="org.postgresql.Driver" export driverSQLServer="com.microsoft.sqlserver.jdbc.SQLServerDriver" diff --git a/weblogic-azure-aks/src/main/arm/scripts/genDatasourceModel.sh b/weblogic-azure-aks/src/main/arm/scripts/genDatasourceModel.sh index e6035ce03..ec7e5ad0e 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/genDatasourceModel.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/genDatasourceModel.sh @@ -25,7 +25,7 @@ resources: JNDIName: [ ${jndiName} ] - GlobalTransactionsProtocol: EmulateTwoPhaseCommit + GlobalTransactionsProtocol: ${GLOBAL_TRANSATION_PROTOCOL} JDBCDriverParams: DriverName: ${driver} URL: '@@SECRET:${secretName}:url@@' diff --git a/weblogic-azure-aks/src/main/arm/scripts/genImageModel.sh b/weblogic-azure-aks/src/main/arm/scripts/genImageModel.sh index 5daf9dad9..6f15e9bce 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/genImageModel.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/genImageModel.sh @@ -33,7 +33,7 @@ domainInfo: AdminUserName: "@@SECRET:__weblogic-credentials__:username@@" AdminPassword: "@@SECRET:__weblogic-credentials__:password@@" ServerStartMode: "prod" - domainLibraries: [ 'wlsdeploy/domainLibraries/postgresql-42.2.8.jar', 'wlsdeploy/domainLibraries/mssql-jdbc-7.4.1.jre8.jar'] + domainLibraries: [ 'wlsdeploy/domainLibraries/postgresql-42.2.8.jar', 'wlsdeploy/domainLibraries/mssql-jdbc-7.4.1.jre8.jar'${dbDriverPaths}] topology: Name: "@@ENV:CUSTOM_DOMAIN_NAME@@" diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 0545a0ed3..6c1b4b9c2 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -78,6 +78,7 @@ param createDNSZone bool = false 'oracle' 'postgresql' 'sqlserver' + 'otherdb' ]) @description('One of the supported database types') param databaseType string = 'oracle' @@ -87,8 +88,16 @@ param databaseType string = 'oracle' ]) @description('createOrUpdate: create a new data source connection, or update an existing data source connection. delete: delete an existing data source connection') param dbConfigurationType string = 'createOrUpdate' +@description('Urls of datasource drivers, must be specified if database type is otherdb') +param dbDriverLibrariesUrls array = [] +@description('Datasource driver name, must be specified if database type is otherdb') +param dbDriverName string = 'org.contoso.Driver' +@description('Determines the transaction protocol (global transaction processing behavior) for the data source.') +param dbGlobalTranPro string = 'EmulateTwoPhaseCommit' @description('Password for Database') param dbPassword string = newGuid() +@description('The name of the database table to use when testing physical database connections. This name is required when you specify a Test Frequency and enable Test Reserved Connections.') +param dbTestTableName string = 'Null' @description('User id of Database') param dbUser string = 'contosoDbUser' @description('DNS prefix for ApplicationGateway') @@ -412,6 +421,7 @@ module wlsDomainDeployment 'modules/setupWebLogicCluster.bicep' = if (!enableCus createACR: createACR createAKSCluster: createAKSCluster createStorageAccount: const_bCreateStorageAccount + dbDriverLibrariesUrls: dbDriverLibrariesUrls enableAzureMonitoring: enableAzureMonitoring enableCustomSSL: enableCustomSSL enableAdminT3Tunneling: enableAdminT3Tunneling @@ -476,6 +486,7 @@ module wlsDomainWithCustomSSLDeployment 'modules/setupWebLogicCluster.bicep' = i createACR: createACR createAKSCluster: createAKSCluster createStorageAccount: const_bCreateStorageAccount + dbDriverLibrariesUrls: dbDriverLibrariesUrls enableAzureMonitoring: enableAzureMonitoring enableCustomSSL: enableCustomSSL enableAdminT3Tunneling: enableAdminT3Tunneling @@ -608,7 +619,10 @@ module datasourceDeployment 'modules/_setupDBConnection.bicep' = if (enableDB) { aksClusterName: ref_wlsDomainDeployment.outputs.aksClusterName.value databaseType: databaseType dbConfigurationType: dbConfigurationType + dbDriverName: dbDriverName + dbGlobalTranPro: dbGlobalTranPro dbPassword: dbPassword + dbTestTableName: dbTestTableName dbUser: dbUser dsConnectionURL: dsConnectionURL identity: identity diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep index e7fafd739..fc0cb7e54 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep @@ -10,6 +10,7 @@ param aksClusterName string = '' param acrName string = '' param appPackageUrls array = [] param appReplicas int = 2 +param dbDriverLibrariesUrls array = [] param enableCustomSSL bool = false param enableAdminT3Tunneling bool = false param enableClusterT3Tunneling bool = false @@ -78,6 +79,12 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { properties: { azCliVersion: '2.15.0' arguments: const_arguments + environmentVariables: [ + { + name: 'URL_3RD_DATASOURCE' + value: '${string(dbDriverLibrariesUrls)}' + } + ] primaryScriptUri: uri(const_scriptLocation, '${const_invokeSetUpDomainScript}${_artifactsLocationSasToken}') supportingScriptUris: [ uri(const_scriptLocation, '${const_setUpDomainScript}${_artifactsLocationSasToken}') diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-datasource-connection.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-datasource-connection.bicep index b647a4bd6..facd11b66 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-datasource-connection.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-datasource-connection.bicep @@ -9,7 +9,10 @@ param aksClusterName string param aksClusterRGName string param databaseType string = 'oracle' param dbConfigurationType string +param dbDriverName string = 'org.contoso.Driver' +param dbGlobalTranPro string = 'EmulateTwoPhaseCommit' param dbPassword string = newGuid() +param dbTestTableName string = 'Null' param dbUser string param dsConnectionURL string param identity object @@ -39,6 +42,20 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { properties: { azCliVersion: const_azcliVersion arguments: const_arguments + environmentVariables: [ + { + name: 'DB_DRIVER_NAME' + value: dbDriverName + } + { + name: 'GLOBAL_TRANSATION_PROTOCOL' + value: dbGlobalTranPro + } + { + name: 'TEST_TABLE_NAME' + value: dbTestTableName + } + ] primaryScriptUri: uri(const_scriptLocation, '${const_invokeSetupDBConnectionsScript}${_artifactsLocationSasToken}') supportingScriptUris: [ uri(const_scriptLocation, '${const_datasourceScript}${_artifactsLocationSasToken}') diff --git a/weblogic-azure-aks/src/main/bicep/modules/_setupDBConnection.bicep b/weblogic-azure-aks/src/main/bicep/modules/_setupDBConnection.bicep index cb2fcbc09..2df8f77d0 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/_setupDBConnection.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/_setupDBConnection.bicep @@ -19,8 +19,14 @@ param databaseType string = 'oracle' 'delete' ]) param dbConfigurationType string = 'createOrUpdate' +@description('Datasource driver name') +param dbDriverName string = 'org.contoso.Driver' +@description('Determines the transaction protocol (global transaction processing behavior) for the data source.') +param dbGlobalTranPro string = 'EmulateTwoPhaseCommit' @description('Password for Database') param dbPassword string = newGuid() +@description('The name of the database table to use when testing physical database connections. This name is required when you specify a Test Frequency and enable Test Reserved Connections.') +param dbTestTableName string = 'Null' @description('User id of Database') param dbUser string = 'contosoDbUser' @description('JDBC Connection String') @@ -53,7 +59,10 @@ module configDataSource '_deployment-scripts/_ds-datasource-connection.bicep' = aksClusterRGName: aksClusterRGName databaseType: databaseType dbConfigurationType: dbConfigurationType + dbDriverName: dbDriverName + dbGlobalTranPro: dbGlobalTranPro dbPassword: dbPassword + dbTestTableName: dbTestTableName dbUser: dbUser dsConnectionURL: dsConnectionURL identity: identity diff --git a/weblogic-azure-aks/src/main/bicep/modules/setupDBConnection.bicep b/weblogic-azure-aks/src/main/bicep/modules/setupDBConnection.bicep index e5a4bf977..688233cc6 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/setupDBConnection.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/setupDBConnection.bicep @@ -17,6 +17,7 @@ Parameters - createOrUpdate: create a new data source connection, or update an existing data source connection. - delete: delete an existing data source connection - dbPassword: Password for Database + - dbGlobalTranPro: Determines the transaction protocol (global transaction processing behavior) for the data source.. - dbUser: User id of Database - dsConnectionURL: JDBC Connection String - identity: Azure user managed identity used, make sure the identity has permission to create/update/delete Azure resources. It's recommended to assign "Contributor" role. @@ -48,6 +49,8 @@ param databaseType string = 'oracle' ]) @description('createOrUpdate: create a new data source connection, or update an existing data source connection. delete: delete an existing data source connection') param dbConfigurationType string = 'createOrUpdate' +@description('Determines the transaction protocol (global transaction processing behavior) for the data source.') +param dbGlobalTranPro string = 'EmulateTwoPhaseCommit' @description('Password for Database') param dbPassword string = newGuid() @description('User id of Database') @@ -81,6 +84,7 @@ module configDataSource './_setupDBConnection.bicep' = { aksClusterRGName: resourceGroup().name databaseType: databaseType dbConfigurationType: dbConfigurationType + dbGlobalTranPro: dbGlobalTranPro dbPassword: dbPassword dbUser: dbUser dsConnectionURL: dsConnectionURL diff --git a/weblogic-azure-aks/src/main/bicep/modules/setupWebLogicCluster.bicep b/weblogic-azure-aks/src/main/bicep/modules/setupWebLogicCluster.bicep index fe69130c8..5c1484294 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/setupWebLogicCluster.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/setupWebLogicCluster.bicep @@ -53,6 +53,7 @@ param createACR bool = false @description('true to create a new AKS cluster.') param createAKSCluster bool = true param createStorageAccount bool = false +param dbDriverLibrariesUrls array = [] @description('In addition to the CPU and memory metrics included in AKS by default, you can enable Container Insights for more comprehensive data on the overall performance and health of your cluster. Billing is based on data ingestion and retention settings.') param enableAzureMonitoring bool = false @description('true to create persistent volume using file share.') @@ -188,6 +189,7 @@ module wlsDomainDeployment './_deployment-scripts/_ds-create-wls-cluster.bicep' acrName: useOracleImage ? (createACR ? acrDeployment.outputs.acrName : acrName) : userProvidedAcr appPackageUrls: appPackageUrls appReplicas: appReplicas + dbDriverLibrariesUrls: dbDriverLibrariesUrls enableCustomSSL: enableCustomSSL enableAdminT3Tunneling: enableAdminT3Tunneling enableClusterT3Tunneling: enableClusterT3Tunneling From 35a959878b319c76836b7256093b36a18eddffc8 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Tue, 19 Oct 2021 16:06:13 +0800 Subject: [PATCH 2/5] On branch galia-3rddb: output error message to deployment output. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh --- weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh b/weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh index fd5283aa8..d5748a1ee 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh @@ -233,7 +233,7 @@ function validate_datasource() { testDatasourceScript=${scriptDir}/${dsScriptFileName} podNum=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.clusterName=${wlsClusterName} -o json | jq '.items| length') if [ ${podNum} -le 0 ]; then - echo "Ensure your cluster has at least one pod." + echo_stderr "Ensure your cluster has at least one pod." exit 1 fi @@ -262,7 +262,7 @@ EOF kubectl exec -it ${podName} -n ${wlsDomainNS} -c ${wlsContainerName} -- bash -c "wlst.sh ${targetDSFilePath}" | grep "State is Running" if [ $? == 1 ];then - echo "Failed to configure datasource ${jdbcDataSourceName}. Please make sure the input values are correct." + echo_stderr "Failed to configure datasource ${jdbcDataSourceName}. Please make sure the input values are correct." delete_datasource exit 1 fi From 3e9be2b21227504ee3c99e3d8b2ce55ab49f5d1f Mon Sep 17 00:00:00 2001 From: galiacheng Date: Tue, 19 Oct 2021 17:01:08 +0800 Subject: [PATCH 3/5] On branch galia-3rddb: increase pom version to 1.0.21 Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/pom.xml --- weblogic-azure-aks/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weblogic-azure-aks/pom.xml b/weblogic-azure-aks/pom.xml index a1fd1123f..e353d445b 100644 --- a/weblogic-azure-aks/pom.xml +++ b/weblogic-azure-aks/pom.xml @@ -11,7 +11,7 @@ com.oracle.weblogic.azure wls-on-aks-azure-marketplace - 1.0.20 + 1.0.21 com.microsoft.azure.iaas From 0fc7b0c8db7b76c9cbfdc597692a8e7ca893ad85 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Thu, 21 Oct 2021 10:52:01 +0800 Subject: [PATCH 4/5] On branch galia-3rddb: enhance UI. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/createUiDefinition.json --- weblogic-azure-aks/src/main/arm/createUiDefinition.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/createUiDefinition.json b/weblogic-azure-aks/src/main/arm/createUiDefinition.json index 2fc7cb742..7c18028dc 100644 --- a/weblogic-azure-aks/src/main/arm/createUiDefinition.json +++ b/weblogic-azure-aks/src/main/arm/createUiDefinition.json @@ -1690,8 +1690,8 @@ "defaultValue": "", "constraints": { "required": true, - "regex": "^[a-z0-9A-Z/]{1,30}$", - "validationMessage": "The value must be 1-30 characters long and must only contain letters, numbers, and slashes (/)." + "regex": "^[a-zA-Z0-9./_-]{1,30}$", + "validationMessage": "The value must be 1-30 characters long and must only contain letters, numbers, hyphens (-), underscores (_), periods (.) and slashes (/)." }, "visible": true }, @@ -1768,7 +1768,7 @@ "defaultValue": "", "constraints": { "required": true, - "regex": "^(?!\\-)([a-z0-9A-Z@\\-]{1,128})([^\\-])$", + "regex": "^(?=.{1,128}$)[a-zA-Z](?!.*--)(?!.*@@)(?!.*-@)(?!.*@-)[a-zA-Z0-9-@]*[a-zA-Z0-9]$", "validationMessage": "The value must be 1-128 characters long and must only contain letters, numbers, hyphen(-) and the at sign, no hyphen allowed at the beginning and the end of database username." }, "visible": true From b7446c29e43cb5729b5be1fdd7c61a37915e1e7f Mon Sep 17 00:00:00 2001 From: Ed Burns Date: Fri, 22 Oct 2021 09:42:03 +0800 Subject: [PATCH 5/5] On branch galia-3rddb: apply Ed's changes to UI. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/createUiDefinition.json --- .../src/main/arm/createUiDefinition.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/createUiDefinition.json b/weblogic-azure-aks/src/main/arm/createUiDefinition.json index 7c18028dc..b1db433ff 100644 --- a/weblogic-azure-aks/src/main/arm/createUiDefinition.json +++ b/weblogic-azure-aks/src/main/arm/createUiDefinition.json @@ -1674,7 +1674,7 @@ "value": "sqlserver" }, { - "label": "Others", + "label": "Other", "value": "otherdb" } ], @@ -1807,6 +1807,16 @@ }, "visible": "[and(bool(steps('section_database').enableDB), equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb'))]" }, + { + "name": "dbDriverInfoBox", + "type": "Microsoft.Common.InfoBox", + "options": { + "icon": "Info", + "text": "WebLogic Server provides support for application data access to any database using a JDBC-compliant driver. Select here for more details.", + "uri": "https://aka.ms/wls-aks-dbdriver" + }, + "visible": "[and(bool(steps('section_database').enableDB), equals(steps('section_database').databaseConnectionInfo.databaseType, 'otherdb'))]" + }, { "name": "dbDriverName", "type": "Microsoft.Common.TextBox", @@ -1924,4 +1934,4 @@ "wlsUserName": "[basics('basicsRequired').wlsUserName]" } } -} \ No newline at end of file +}