SQL Database from Azure CLI

Hi, i want to share another Azure CLI script, Bash based to deploy an Azure SQL server and also the database, even we include the authorized ip address.

Try the following changing the bold words.

#!/bin/bash
# Set an admin login and password for your database
export adminlogin=ServerAdmin
export password=ChangeYourAdminPassword1
# The logical server name has to be unique in the system
export servername=server-$RANDOM
# The ip address range that you want to allow to access your DB
export startip=0.0.0.0
export endip=0.0.0.0
# Create a resource group
az group create -name myResourceGroup –location westeurope
# Create a logical server in the resource group
az sql server create –name $servername –resource-group myResourceGroup –location westeurope –admin-user $adminlogin –admin-password $password
# Configure a firewall rule for the server
az sql server firewall-rule create –resource-group myResourceGroup –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 myResourceGroup –server $servername –name mySampleDatabase –sample-name AdventureWorksLT –service-objective S0 –zone-redundant
# Update database and set zone redundancy as false
az sql db update –resource-group myResourceGroup –server $servername –name mySampleDatabase –zone-redundant false

Dejar un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *