Skip to content

Instantly share code, notes, and snippets.

@berberich
Created November 12, 2019 22:45
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 berberich/b1a3aa5cb08ca05c7280f795896061ee to your computer and use it in GitHub Desktop.
Save berberich/b1a3aa5cb08ca05c7280f795896061ee to your computer and use it in GitHub Desktop.
#!/bin/bash
# Update for your admin password
AdminPassword=MySup3RS3cRe7P@S$W0Rd
# Create a resource group.
# az group create --name myResourceGroup --location eastus
az network vnet create --resource-group myResourceGroup --name sqlvmVnet --subnet-name sqlSubnet
# Create a public IP address.
az network public-ip create --resource-group myResourceGroup --name myPublicIP
# Create a network security group.
az network nsg create --resource-group myResourceGroup --name myNetworkSecurityGroup
# Create a virtual network card and associate with public IP address and NSG.
az network nic create \
--resource-group myResourceGroup \
--name myNic \
--vnet-name sqlvmVnet \
--subnet sqlSubnet \
--network-security-group myNetworkSecurityGroup \
--public-ip-address myPublicIP
# Create a virtual machine.
az vm create \
--resource-group myResourceGroup \
--name sqlVM \
--location westus2 \
--nics myNic \
--image MicrosoftSQLServer:SQL2016SP2-WS2016:Standard:Latest \
--size Standard_D3_v2
--admin-username azureuser \
--admin-password $AdminPassword
# Open port 3389 to allow RDP traffic to host.
az vm open-port --port 3389 --resource-group myResourceGroup --name sqlVM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment