Skip to content

Commit

Permalink
added enable aggregation pipeline to azure mongo
Browse files Browse the repository at this point in the history
fixed azure sql fog binding credentials

fixes #135
  • Loading branch information
Ernie Billing committed Nov 13, 2020
1 parent 5b49e9f commit 36b3f3b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
6 changes: 6 additions & 0 deletions acceptance-tests/spring-music-validator/sqlserver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ function sqlserverQuerySpringMusic(pool) {

module.exports = async function (credentials, runServer) {
let content = ""

if (credentials.hostname != credentials.sqlServerFullyQualifiedDomainName ||
credentials.name != credentials.sqldbName) {
console.error("hostname does not match sqlServerFullyQualifiedDomainName or name does not match sqldbName ")
throw new Error("badly formed credentials")
}
return connectSqlserver({
server: credentials.hostname,
user: credentials.username,
Expand Down
5 changes: 4 additions & 1 deletion azure-brokerpak/azure-mssql-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,31 @@ plans:
description: 'SQL Server latest version. Instance properties: General Purpose - Serverless ; 0.5 - 2 cores ; Max Memory: 6gb ; 50 GB storage ; auto-pause enabled after 1 hour of inactivity'
display_name: "Small"
properties:
subsume: false
- name: medium
id: 3ee14bce-33e8-4d02-9850-023a66bfe120
description: 'SQL Server latest version. Instance properties: General Purpose - Provisioned ; Provisioned Capacity ; 8 cores ; 200 GB storage'
display_name: "Medium"
properties:
cores: 8
max_storage_gb: 200
subsume: false
- name: large
id: 8f1c9c7b-80b2-49c3-9365-a3a059df9907
description: 'SQL Server latest version. Instance properties: Business Critical ; Provisioned Capacity ; 32 cores ; 500 GB storage'
display_name: "Large"
properties:
cores: 32
max_storage_gb: 500
subsume: false
- name: extra-large
id: 09096759-58a8-41d0-96bf-39b02a0e4104
description: 'SQL Server latest version. Instance properties: Business Critical ; Provisioned Capacity ; 80 cores ; 1 TB storage'
display_name: "Extra Large"
properties:
cores: 80
max_storage_gb: 1024
subsume: false
- name: subsume
id: 7781fa41-f486-447a-942c-ded8cccb8299
description: 'Subsume control of an existing SQL Database'
Expand Down Expand Up @@ -77,7 +81,6 @@ provision:
plan_inputs:
- field_name: subsume
type: boolean
default: false
details: Subsume existing DB
user_inputs:
- field_name: cores
Expand Down
4 changes: 4 additions & 0 deletions azure-brokerpak/terraform/azure-mongodb/azure-mongodb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ resource "azurerm_cosmosdb_account" "mongo-account" {
enable_multiple_write_locations = var.enable_multiple_write_locations
ip_range_filter = var.ip_range_filter
tags = var.labels

capabilities {
name = "EnableAggregationPipeline"
}
}

resource "azurerm_cosmosdb_mongo_database" "mongo-db" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

locals {
serverFQDN = var.existing ? format("%s.database.windows.net", var.instance_name) : format("%s.database.windows.net", azurerm_sql_failover_group.failover_group[0].name)
serverName = var.existing ? var.instance_name : azurerm_sql_failover_group.failover_group[0].name
serverFQDN = format("%s.database.windows.net", local.serverName)
dbName = var.existing ? var.db_name : azurerm_mssql_database.primary_db[0].name
}

output sqldbName {value = var.db_name}
output sqlServerName {value = var.instance_name}
output sqldbName {value = local.dbName}
output sqlServerName {value = local.serverName}
output sqlServerFullyQualifiedDomainName {value = local.serverFQDN}
output hostname {value = local.serverFQDN}
output port {value = 1433}
output name {value = var.existing ? var.db_name : azurerm_mssql_database.primary_db[0].name}
output name {value = local.dbName}
output username {value = var.server_credential_pairs[var.server_pair].admin_username}
output password {value = var.server_credential_pairs[var.server_pair].admin_password}
output status {
Expand Down
41 changes: 41 additions & 0 deletions scripts/azure-create-mssql-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -o pipefail
set -o nounset
#set -o errexit

if [ $# -lt 3 ]; then
echo "Usage: ${0} <resource group> <server name> <location>"
exit 1
fi

RG=${1}; shift
SERVER_NAME=${1}; shift
LOCATION=${1}; shift

USERNAME=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z' | fold -w 16 | head -n 1)
PASSWORD=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)

if [ $# -gt 0 ]; then
USERNAME=$1; shift
fi

if [ $# -gt 0 ]; then
PASSWORD=$1; shift
fi

DB_NAME=csb-db

az sql server create --resource-group ${RG} --name ${SERVER_NAME} --location ${LOCATION} --admin-user ${USERNAME} --admin-password ${PASSWORD}

az sql server firewall-rule create --resource-group ${RG} --server ${SERVER_NAME} --name ${SERVER_NAME}-ip --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0

az sql db create --name ${DB_NAME} --resource-group ${RG} --server ${SERVER_NAME} -e GeneralPurpose -f Gen5 -c 2 --compute-model Serverless --auto-pause-delay 120

DETAILS=$(az sql server show --resource-group ${RG} --name ${SERVER_NAME})

echo Server Details
echo FQDN: $(echo ${DETAILS} | jq -r .fullyQualifiedDomainName)
echo Admin Username: ${USERNAME}@${SERVER_NAME}
echo Admin Password: ${PASSWORD}
echo Database Name: ${DB_NAME}

0 comments on commit 36b3f3b

Please sign in to comment.