Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created June 24, 2016 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/4fb1f7dbac88d7634fd964b60a785d86 to your computer and use it in GitHub Desktop.
Save codingoutloud/4fb1f7dbac88d7634fd964b60a785d86 to your computer and use it in GitHub Desktop.
$subName = 'my azure subscription name here'
$rgName = 'nesql-june24-demo2'
$region = "East US"
$serverName = 'billwilder911'
$myIp = "107.92.120.203" #### CHANGES A LOT!
Add-AzureRmAccount # then log in interactively, including with 2FA
Select-AzureRmSubscription -SubscriptionName $subName
# How many regions am I allowed to deploy SQL to?
$sqlRegionCount = (Get-AzureRmResourceProvider -ListAvailable | Where-Object {$_.ProviderNamespace -eq 'Microsoft.Sql'}).Locations.Length
Write-Host "$sqlRegionCount regions available for creating Azure SQL Databases:"
(Get-AzureRmResourceProvider -ListAvailable | Where-Object {$_.ProviderNamespace -eq 'Microsoft.Sql'}).Locations
# create a RESOURCE GROUP for this demo
New-AzureRmResourceGroup -Name $rgName -Location $region
(Get-AzureRmResourceGroup -Name $rgName).Location
# create a DATABASE SERVER
New-AzureRmSqlServer -ResourceGroupName $rgName -ServerName $serverName -Location $region -ServerVersion "12.0"
#create a DATABASE FIREWALL RULE
New-AzureRmSqlServerFirewallRule `
-ResourceGroupName $rgName `
-ServerName $serverName -FirewallRuleName "one ip to rule them all" `
-StartIpAddress $myIp -EndIpAddress $myIp
# -AllowAllAzureIPs
# create a DATABASE ************************************
Get-AzureRmSqlCapability -LocationName $region
$dbName = 'BillDb'
$dbEdition = "Basic"
$dbLevel = "S0" # https://azure.microsoft.com/en-us/documentation/articles/sql-database-service-tiers/
$dbLevel = "Basic" # https://azure.microsoft.com/en-us/documentation/articles/sql-database-service-tiers/
$db = New-AzureRmSqlDatabase -ResourceGroupName $rgname `
-ServerName $serverName `
-DatabaseName $dbname `
-Edition $dbEdition `
-RequestedServiceObjectiveName $dbLevel
$db
Write-Host "Firewall?"
Write-Host "${dbName}.database.secure.windows.net"
# comment out to NOT delete right away
Write-Host "Remove-AzureRmResourceGroup -Name $rgname -Force"
$subName = 'Bill Wilder - Finomial MSDN(Converted to EA)'
$rgName = 'nesql-june24-demo2'
$region = "East US"
$serverName = 'billserver981'
$myIp = "107.92.120.203" #### CHANGES A LOT!
Add-AzureRmAccount # then log in interactively, including with 2FA
Select-AzureRmSubscription -SubscriptionName $subName
# How many regions am I allowed to deploy SQL to?
$sqlRegionCount = (Get-AzureRmResourceProvider -ListAvailable | Where-Object {$_.ProviderNamespace -eq 'Microsoft.Sql'}).Locations.Length
Write-Host "$sqlRegionCount regions available for creating Azure SQL Databases:"
(Get-AzureRmResourceProvider -ListAvailable | Where-Object {$_.ProviderNamespace -eq 'Microsoft.Sql'}).Locations
# create a RESOURCE GROUP for this demo
New-AzureRmResourceGroup -Name $rgName -Location $region
(Get-AzureRmResourceGroup -Name $rgName).Location
# create a DATABASE SERVER
New-AzureRmSqlServer -ResourceGroupName $rgName -ServerName $serverName -Location $region -ServerVersion "12.0"
#create a DATABASE FIREWALL RULE
New-AzureRmSqlServerFirewallRule `
-ResourceGroupName $rgName `
-ServerName $serverName -FirewallRuleName "one ip to rule them all" `
-StartIpAddress $myIp -EndIpAddress $myIp
# -AllowAllAzureIPs
# create a DATABASE ************************************
Get-AzureRmSqlCapability -LocationName $region
$dbName = 'BillDb'
$dbEdition = "Basic"
$dbLevel = "S0" # https://azure.microsoft.com/en-us/documentation/articles/sql-database-service-tiers/
$dbLevel = "Basic" # https://azure.microsoft.com/en-us/documentation/articles/sql-database-service-tiers/
$db = New-AzureRmSqlDatabase -ResourceGroupName $rgname `
-ServerName $serverName `
-DatabaseName $dbname `
-Edition $dbEdition `
-RequestedServiceObjectiveName $dbLevel
$db
Write-Host "${dbName}.database.secure.windows.net"
Write-Host "Run this later to delete this resource group containing database server and database"
Write-Host "Remove-AzureRmResourceGroup -Name $rgname -Force"
#Remove-AzureRmResourceGroup -Name $rgname -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment