Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dbUser = "tester"
- $dbPass = "myP@ssword"
- $primaryServerName = "serverName"
- $primaryDbName = "dbName"
- $resourceGroupName = "groupName"
- $secondaryServerName = "secondary" + (Get-Random)
- $existingDb = Get-AzureRmSqlDatabase -ServerName $primaryServerName -DatabaseName $primaryDbName `
- -ResourceGroupName $resourceGroupName
- # Create secondary server
- $securePass = ConvertTo-SecureString -String $dbPass -AsPlainText -Force
- $dbCredentials = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $dbUser, $securePass
- $serverSecondary = New-AzureRmSqlServer -ServerName $secondaryServerName `
- -ResourceGroupName $existingDb.ResourceGroupName -Location "West Europe" `
- -SqlAdministratorCredentials $dbCredentials
- # Activate geo-replication
- $existingDb | New-AzureRmSqlDatabaseSecondary `
- -PartnerServerName $secondaryServerName `
- -PartnerResourceGroupName $existingDb.ResourceGroupName
- # To allow connections to your secondary DB just add -AllowConnections All
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement