# ****************************************************** # * # * Name: create-azure-sqldb-schema.ps1 # * # * Design Phase: # * Author: John Miner # * Date: 08-05-2017 # * Purpose: From client workstation to cloud # * database. # * # ****************************************************** # Root name for objects in this script $root = "tips17" # # 1 - Azure Subscriptions # # Prompts you for azure credentials Add-AzureRmAccount # Clear the screen Clear-Host # List my subscriptions Get-AzureRmSubscription # # 2 - Create a resource group # # New resource group # New-AzureRmResourceGroup -Name "rg4$root" -Location "East US 2" # Clear the screen Clear-Host # List resource groups Get-AzureRmResourceGroup -Name "rg4$root" # Delete resource group # Remove-AzureRmResourceGroup -Name "rg4$root" -Force # # 3 - Create a new server # # User n Secret $User = "jminer" $Secret = 'MS#tIpS$2017' # Create a credential $Pwd = ConvertTo-SecureString –String $Secret –AsPlainText -Force $Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $Pwd # New sql server New-AzureRmSqlServer -ResourceGroupName "rg4$root" -ServerName "sql4$root" -Location "East US 2" -ServerVersion "12.0" -SqlAdministratorCredentials $Credential # Clear the screen Clear-Host Write-Host # List Sql Servers Get-AzureRmSqlServer -ResourceGroupName "rg4$root" # Remove the sql server #Remove-AzureRmSqlServer -ResourceGroupName "rg4$root" -ServerName "sql4$root" # # 4 - Add laptop ip to firewall (todo = code to figure out ip since I am behind a router) # # Create new firewall rule New-AzureRmSqlServerFirewallRule -ResourceGroupName "rg4$root" -ServerName "sql4$root" -FirewallRuleName "fr4laptop" -StartIpAddress "96.238.35.33" -EndIpAddress "96.238.35.33" # Clear the screen Clear-Host Write-Host # List firewall rules Get-AzureRmSqlServerFirewallRule -ResourceGroupName "rg4$root" -ServerName "sql4$root" # Remove firewall rule # Remove-AzureRmSqlServerFirewallRule -ResourceGroupName "rg4$root" -ServerName "sql4$root" -FirewallRuleName "fr4laptop"