Deleted Bulk Schema Deployment with MSSQL-Scripter & PowerShell
This commit is contained in:
Родитель
914962f471
Коммит
a06c317a49
|
@ -1,29 +0,0 @@
|
|||
# /***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
######################################################################################################################################################
|
||||
# Author: Paula Berenguel - Jul-17
|
||||
# Description: This script will create a elastic pool and add databases to it
|
||||
# How to run the script: & "C:\MyPS\add_elastic.ps1"
|
||||
######################################################################################################################################################
|
||||
|
||||
# variables declaration
|
||||
$resourcegroupname = "mls_rg"
|
||||
$location = "East US"
|
||||
$servername = "mls1dev"
|
||||
$databasename = @("Northwind", "AdventureWorks2012", "ContosoRetailDW")
|
||||
$elasticpoolname = "elasticmls1"
|
||||
|
||||
|
||||
$elasticname =Get-AzureRmSqlElasticPool -ResourceGroupName $resourcegroupname -ServerName $servername
|
||||
if ( -not $elasticname) {
|
||||
Write-Output "Could not find Elastic Pool '$elasticpoolname' - will create it"
|
||||
Write-Output "Creating Elastic Pool '$elasticpoolname'"
|
||||
New-AzureRmSqlElasticPool -ResourceGroupName $resourcegroupname -ServerName $servername -ElasticPoolName $elasticpoolname -Edition "Basic"
|
||||
|
||||
For ($i=0; $i -lt $databasename.Length; $i++) {
|
||||
Set-AzureRmSqlDatabase -ResourceGroupName $resourcegroupname -DatabaseName $databasename[$i] -ServerName $servername -ElasticPoolName $elasticpoolname
|
||||
}
|
||||
}
|
||||
else{
|
||||
Write-Output "Using existing Elastic Pool '$elasticpoolname'"
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
# /***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
############################################################################################################
|
||||
# Author: Paula Berenguel - Jul-17
|
||||
# Description: This PowerShell script will create a resource group named mls_rg in EAST US location
|
||||
# How to run the script: & "C:\MyPS\create_rg.ps1"
|
||||
############################################################################################################
|
||||
|
||||
|
||||
# variables declaration
|
||||
$resourcegroupname = "mls_rg"
|
||||
$location = "East US"
|
||||
|
||||
|
||||
##creating the resource group called mls_rg in the location East US
|
||||
$resourceGroup = Get-AzureRmResourceGroup -Name $resourcegroupname -Location $location -ErrorAction SilentlyContinue
|
||||
if ( -not $ResourceGroup ) {
|
||||
Write-Output "Could not find resource group '$resourcegroupname' - will create it"
|
||||
Write-Output "Creating resource group '$resourcegroupname' in location '$location'"
|
||||
New-AzureRmResourceGroup -Name $resourcegroupname -Location $location
|
||||
}
|
||||
else {
|
||||
Write-Output "Resource group '$ResourceGroupName' already exists"
|
||||
}
|
||||
|
||||
|
||||
## Validation:
|
||||
## go to Azure and verify Resource Group was created succesfully or, simply run this script again.
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
######################################################################################################################################################
|
||||
# Author: Paula Berenguel - Jul-17
|
||||
# Description: This script will create one or more of empty databases in the server named mls1dev.
|
||||
# The list of databases should be specified in the $databasename variable
|
||||
# Databases will be creating in Standard S3 tier
|
||||
# RequestedServiceObjectiveName possible values include: 'Basic', 'S0', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3', 'P4', 'P6', 'P11', 'P15'
|
||||
# How to run the script: & "C:\MyPS\create_sqldb.ps1"
|
||||
######################################################################################################################################################
|
||||
|
||||
# variables declaration
|
||||
$resourcegroupname = "mls_rg" #resourcegroup
|
||||
$location = "East US" #location
|
||||
|
||||
|
||||
$servername = "mls1dev" #servername
|
||||
$startip = "0.0.0.0" #startIP address for creating Firewall rules to azure services
|
||||
$endip = "0.0.0.0" #endip address for creating Firewall rules to azure services
|
||||
|
||||
|
||||
$databasename = @("Northwind", "AdventureWorks2012", "ContosoRetailDW") # List of databases -
|
||||
|
||||
## database creation
|
||||
For ($i=0; $i -lt $databasename.Length; $i++) {
|
||||
$azuresqldb= Get-AzureRmSqlDatabase -ResourceGroupName $resourcegroupname -ServerName $servername -DatabaseName $databasename[$i] -ErrorAction SilentlyContinue
|
||||
if ( -not $azuresqldb ) {
|
||||
"Creating Azure SQL Database " + $databasename[$i] + " in Server Name '$servername'"
|
||||
# Standard Tier.
|
||||
New-AzureRmSqlDatabase -ResourceGroupName $resourcegroupname -ServerName $servername -DatabaseName $databasename[$i] -RequestedServiceObjectiveName "S3"
|
||||
}
|
||||
else{
|
||||
"Azure SQL Database already exists " + $databasename[$i]
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
#/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
############################################################################################################
|
||||
# Author: Paula Berenguel - Jul-17
|
||||
# Description: This PowerShell script will create an Azure SQL Server named mls1dev
|
||||
# How to run the script: & "C:\MyPS\create_sqlserver.ps1"
|
||||
############################################################################################################
|
||||
|
||||
|
||||
# variables declaration
|
||||
$resourcegroupname = "mls_rg"
|
||||
$location = "East US"
|
||||
|
||||
# do not capitalize
|
||||
$servername = "mls1dev"
|
||||
$adminlogin = "corp"
|
||||
$password = "NorthStar2015"
|
||||
|
||||
# The ip address range that you want to allow to access your server - change as appropriate
|
||||
$startip = "0.0.0.0"
|
||||
$endip = "0.0.0.0"
|
||||
|
||||
# List of databases
|
||||
$databasename = @("Northwind", "AdventureWorks2012", "ContosoRetailDW")
|
||||
|
||||
|
||||
$sqlservername =Get-AzureRmSqlServer -ResourceGroupName $resourcegroupname -ServerName $servername -ErrorAction SilentlyContinue
|
||||
if ( -not $sqlservername) {
|
||||
Write-Output "Could not find Azure SQL Server '$servername' - will create it"
|
||||
Write-Output "Creating Azure SQL Server '$servername', resource group '$resourcegroupname' in location '$location'"
|
||||
New-AzureRmSqlServer -ResourceGroupName $resourcegroupname -ServerName $servername -Location $location -SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $adminlogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))
|
||||
Write-Output "Setting up Firewall Rule"
|
||||
New-AzureRmSqlServerFirewallRule -ResourceGroupName $resourcegroupname -ServerName $servername -FirewallRuleName "AllowSome" -StartIpAddress $startip -EndIpAddress $endip
|
||||
}
|
||||
else{
|
||||
Write-Output "Azure SQL Server '$servername' already exists"
|
||||
}
|
||||
|
||||
|
||||
## Validation:
|
||||
## go to Azure and verify SQL Server was created succesfully or, simply run this script again.
|
|
@ -1,10 +0,0 @@
|
|||
#/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
##########################################################################
|
||||
# Creator: Paula Berenguel - Jul/2017
|
||||
# This PowerShell script will remove a resource group named mlsresource,
|
||||
# How to run the script: & "C:\MyPS\remove_rg.ps1"
|
||||
############################################################################
|
||||
|
||||
# ResourceGroup name
|
||||
$resourcegroupname = "mls_rg"
|
||||
Remove-AzureRmResourceGroup -ResourceGroupName $resourcegroupname
|
|
@ -1,44 +0,0 @@
|
|||
#/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
##########################################################################
|
||||
# This PowerShell script will deploy an schema to a Azure SQL db
|
||||
# How to run the script? & "C:\MyPS\schema_deploy.ps1"
|
||||
############################################################################
|
||||
|
||||
|
||||
|
||||
# The data center and resource group name
|
||||
$resourcegroupname = "mls_rg"
|
||||
$location = "East US"
|
||||
|
||||
# The logical server name: Use a random value or replace with your own value (do not capitalize)
|
||||
$servername = "mls1dev"
|
||||
$adminlogin = "corp"
|
||||
$password = "NorthStar2015"
|
||||
|
||||
# The ip address range that you want to allow to access your server - change as appropriate
|
||||
$startip = "0.0.0.0"
|
||||
$endip = "0.0.0.0"
|
||||
|
||||
# List of databases
|
||||
$databasename = @("Northwind", "AdventureWorks2012", "ContosoRetailDW")
|
||||
|
||||
$DBDataPath = "C:\Python36-32\"
|
||||
$DBLogPath = "C:\Python36-32\"
|
||||
|
||||
|
||||
$DBScriptFile=''
|
||||
$DBLogPathFile=''
|
||||
For ($i=0; $i -lt $databasename.Length; $i++) {
|
||||
$azuresqldb= Get-AzureRmSqlDatabase -ResourceGroupName $resourcegroupname -ServerName $servername -DatabaseName $databasename[$i] -ErrorAction SilentlyContinue
|
||||
if ( -not $azuresqldb ) { #checking for database existence
|
||||
"Could not find Azure SQL Database " + $databasename[$i]
|
||||
}
|
||||
else{
|
||||
$DBScriptFile = $DBDataPath + $databasename[$i] + '.sql'
|
||||
$DBLogPathFile = $DBLogPath + $databasename[$i] + '_log.txt'
|
||||
sqlcmd -U corp -S mls1dev.database.windows.net -P $password -d $databasename[$i] -j -i $DBScriptFile -o $DBLogPathFile
|
||||
"Azure SQL Database " + $databasename[$i] + " deployed"
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
##########################################################################
|
||||
# This PowerShell script will create a resource group named mlsresource,
|
||||
# An Azure SQL Server named psserver1 and a list of Azure SQL Databases (psdb1 and psdb2)
|
||||
# within psserver1 server - Basic Tier
|
||||
# How to run the script? & "C:\MyPS\schema_generator.ps1"
|
||||
############################################################################
|
||||
|
||||
$databasename = @("Northwind", "AdventureWorks2012", "ContosoRetailDW")
|
||||
|
||||
$File ="C:\MyPS\schema_run.ps1"
|
||||
Clear-Content $File
|
||||
#Get-Date + "#"| Out-File $File
|
||||
For ($i=0; $i -lt $databasename.Length; $i++) {
|
||||
$dbscripter = "mssql-scripter -S MININT-H014C12 -d " + $databasename[$i] + " -U sa -P StarWars2017 --script-create --exclude-headers --check-for-existence -f C:\Python36-32\" + $databasename[$i] + ".sql --continue-on-error --target-server-version AzureDB --display-progress --exclude-use-database" | Out-File $File -append
|
||||
}
|
||||
|
||||
& "C:\MyPS\schema_run.ps1"
|
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -1,4 +0,0 @@
|
|||
/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
||||
Creates a resource group, 1 or multiple sql servers to host one or multiple Azure SQL DBs,
|
||||
export every schema from a SQL Server (or multiple SQL Servers (2005+) on premises (or VM) and
|
||||
import it to Azure SQL DB
|
|
@ -1 +0,0 @@
|
|||
/***This Artifact belongs to the Data SQL Ninja Engineering Team***/
|
Загрузка…
Ссылка в новой задаче