Creating a SQL Server and Database in Azure with CLI

Bash

The bash code creates a Microsoft Azure resource group called "NewApp" in the "East US" region. It then creates a SQL server called "new-app-sql-server" with an admin user and password, and creates a firewall rule that allows access to the SQL server from a specific IP range. Finally, it creates a serverless database called "new-app" with additional settings that declare the database edition and capacity.

The General Purpose edition is designed to support a wide range of workloads, from small-scale transactional applications to large-scale data warehousing and analytics

location="East US"
resourceGroup="NewApp"
server="new-app-sql-server"
database="new-app"
login="****"
password="****"
startIp="****"
endIp="*****"

az group create --name $resourceGroup --location "$location" 

az sql server create --name $server --resource-group $resourceGroup --location "$location" --admin-user $login --admin-password $password 

az sql server firewall-rule create --resource-group $resourceGroup --server $server -n AllowYourIp --start-ip-address $startIp --end-ip-address $endIp 

az sql db create  --resource-group $resourceGroup --server $server --name $database --edition GeneralPurpose --compute-model Serverless --family Gen5 --capacity 2
Did you find this snippet useful?

Sign up for free to to add this to your code library