Skip to content

Instantly share code, notes, and snippets.

@danielscholl
Created April 21, 2017 22:07
Show Gist options
  • Save danielscholl/fdec5d8be100a59ce766d0c38a73f7eb to your computer and use it in GitHub Desktop.
Save danielscholl/fdec5d8be100a59ce766d0c38a73f7eb to your computer and use it in GitHub Desktop.
Azure CLI 2.0 Load Balance Rule Set Addition (Simple)
#!/bin/bash
#set -o errexit -o pipefail
RESOURCE_GROUP=<your_resource_group>
if [[ ! $1 ]]; then
echo "\$1 Protocol Argument Required"
exit 1
fi
if [[ ! $2 ]]; then
echo "\$1 Port Argument Required"
exit 1
fi
PROTOCOL=$1
PORT=$2
NAME="${PROTOCOL}_${PORT}"
LOAD_BALANCER=($(az network lb list --resource-group ${RESOURCE_GROUP} | jq -r '.[0].name'))
FRONT_END=($(az network lb frontend-ip list --resource-group ${RESOURCE_GROUP} --lb-name ${LOAD_BALANCER} | jq -r '.[0].name'))
BACK_END=($(az network lb address-pool list --resource-group ${RESOURCE_GROUP} --lb-name ${LOAD_BALANCER} | jq -r '.[0].name'))
az network lb probe create --resource-group ${RESOURCE_GROUP} --lb-name ${LOAD_BALANCER}\
--name ${NAME} --protocol ${PROTOCOL} --port ${PORT} --path '/'
az network lb rule create --resource-group ${RESOURCE_GROUP} --lb-name ${LOAD_BALANCER}\
--backend-pool-name ${BACK_END} --backend-port ${PORT}\
--frontend-ip-name ${FRONT_END} --frontend-port ${PORT}\
--probe-name ${NAME}\
--name ${NAME} --protocol TCP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment