Skip to content

Instantly share code, notes, and snippets.

@flytzen
Created December 7, 2021 15:18
Show Gist options
  • Save flytzen/d70c3d11ed8a387e46a3ed99bd60981b to your computer and use it in GitHub Desktop.
Save flytzen/d70c3d11ed8a387e46a3ed99bd60981b to your computer and use it in GitHub Desktop.
Create Locust Server - in progress
#!/bin/sh
# NOTE: On WSL, if you have not explicitly installed the az cli in the shell, it will use the one in windows.
# In that case, the ssh key will put into a windows directory and won't subseqentl be used when trying to ssh to the vm
group=fl-locust-test
location=northeurope
vmName=fl-locust-server
uid=locustuser
az group create --name $group --location $location
az vm create \
--resource-group $group \
--name $vmName \
--image Canonical:UbuntuServer:18.04-LTS:latest \
--public-ip-sku Standard \
--admin-username $uid \
--generate-ssh-keys \
--authentication-type ssh \
--size Standard_D4s_v3
# --custom-data
az vm open-port --port 80 --resource-group $group --name $vmName
ip=`az vm list-ip-addresses --name fl-locust-server -g fl-locust-test --query [0].virtualMachine.network.publicIpAddresses[0].ipAddress -o tsv`
ssh $username@$ip sudo apt update && sudo apt -y install python3-pip && sudo pip3 install locust
echo you can connect to the vm via ssh : ssh $username@$ip to start the server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment