Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add postgres support and fix typo #64

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scripts/provision/lib/azure/db/postgres_support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { PostgreSQLManagementClient, PostgreSQLManagementClientContext, Servers, Databases, VirtualNetworkRules } = require('@azure/arm-postgresql')

const serversClient = contextClient => new Servers(contextClient)

const managementClient = (credentials, subscriptionId) => new PostgreSQLManagementClient(credentials, subscriptionId)

const contextClient = (credentials, subscriptionId) => new PostgreSQLManagementClientContext(credentials, subscriptionId)


const createInitDb = async(resourceGroupName, serverName, databaseName, contextClient) => {
const dataBases = new Databases(contextClient)
await dataBases.beginCreateOrUpdate(resourceGroupName, serverName, databaseName, {})
}

const subnetService = () => 'Microsoft.Sql'

const createVirtualNetworkRule = async(serverName, resourceGroupName, virtualNetwork, contextClient) => {
const virtualNetworkRulesClient = new VirtualNetworkRules(contextClient)
await virtualNetworkRulesClient.beginCreateOrUpdate(resourceGroupName, serverName, virtualNetwork.name, { 'virtualNetworkSubnetId': virtualNetwork.subnets[0].id })
}

module.exports = {
serversClient, managementClient, contextClient, createInitDb, subnetService, createVirtualNetworkRule
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ConfigWriter {
this.credentials = credentials
this.azureCreds = new DefaultAzureCredential()
this.keyVaultManagementClient = new KeyVaultManagementClient(this.azureCreds, credentials.subscriptionId)
this.networkManagementClient = new NetworkManagementClient(this.azureCreds, credentials.subscriptionId)
this.networkClient = new NetworkManagementClient(this.azureCreds, credentials.subscriptionId)
this.subscriptionClient = new SubscriptionClient(this.azureCreds)
this.userObjectId = credentials.userObjectId
this.region = region
Expand Down
2 changes: 2 additions & 0 deletions scripts/provision/lib/cloud-providers/azure/db/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const clientFor = engine => {
switch (engine) {
case 'mysql':
return require('./mysql_support')
case 'postgres':
return require ('./postgres_support')
}
}

Expand Down
1 change: 1 addition & 0 deletions scripts/provision/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@azure/arm-keyvault": "^1.3.2",
"@azure/arm-mysql": "^4.0.0",
"@azure/arm-network": "^25.2.0",
"@azure/arm-postgresql": "^5.2.0",
"@azure/arm-resources": "^4.2.2",
"@azure/arm-subscriptions": "^3.1.2",
"@azure/identity": "^1.5.2",
Expand Down