Skip to content

Instantly share code, notes, and snippets.

@wenqiglantz
Created January 8, 2022 04:48
Show Gist options
  • Save wenqiglantz/fd93b0a5f583afa5c1ed93b8a7ebc639 to your computer and use it in GitHub Desktop.
Save wenqiglantz/fd93b0a5f583afa5c1ed93b8a7ebc639 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set an admin login and password for your database
export adminlogin=<admin username>
export password=<admin password>
# The logical server name has to be unique in the system
export servername=<SQL server name>
# The ip address range that you want to allow to access your DB
export startip=0.0.0.0
export endip=223.255.255.255
# the name of the resource group
export rg=<resource group>
# the name of the databases
export db=<database name>
# Create a logical server in the resource group
az sql server create \
--name $servername \
--resource-group $rg \
--admin-user $adminlogin \
--admin-password $password
# Configure a firewall rule for the server
az sql server firewall-rule create \
--resource-group $rg \
--server $servername \
-n AllowYourIp \
--start-ip-address $startip \
--end-ip-address $endip
# Create a database in the server with zone redundancy as true
az sql db create \
--resource-group $rg \
--server $servername \
--name $db \
--service-objective Basic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment