Introduction
How to install SQL Server on an Azure VM.
Adapted from:
with this:
Articles Related
Step
- Install Azure cli 2.0
- Create the machine
az.cmd vm create ^
--resource-group myResourceGroup ^
--name MSFT-DB-01 ^
--image MicrosoftSQLServer:SQL2017-RHEL7:SQLDEV:14.0.1000206 ^
--size Standard_DS1_V2 ^
--authentication-type password ^
--admin-username adm ^
--admin-password pwd ^
--location westeurope
- Change the SA password
sudo systemctl stop mssql-server
sudo /opt/mssql/bin/mssql-conf set-sa-password
sudo systemctl start mssql-server
- Add the tools package (sqlcmd and bcp) to your path
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
- Add remote access in the local Firewall
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload
- Add remote access on the VM only for your IP
az.cmd network nsg rule create ^
--resource-group myGroup ^
--nsg-name MSFT-DB-01NSG ^
--name allow-sqlserver-hi ^
--protocol tcp ^
--priority 1010 ^
--destination-port-range 1433 ^
--source-address-prefixes yourStaticIP
That's it.
Test it:
sqlcmd -S localhost -U SA -P pwd
Admin script
- Admin script: Start / What's my IP / Stop
az.cmd vm start --name MSFT-DB-01 --resource-group myGroup
az.cmd vm show --name MSFT-DB-01 --resource-group myGroup -d --query [publicIps] --o tsv
az.cmd vm stop --name MSFT-DB-01 --resource-group myGroup