Azure DevOps hosted ubuntu agent issue updating Application Gateway
up vote
0
down vote
favorite
I deployed some infra using Terraform, including an application gateway. Unfortunately not all settings can be set/updated with terraform. SO I have a shell script that updates the application gateway.
#!/bin/bash
SP_ID=${1}
SP_SECRET=${2}
TENANT_ID=${3}
SUBSCRIPTION=${4}
RG=${5}
az login --service-principal -u ${SP_ID} -p ${SP_SECRET} -t ${TENANT_ID}
az account set --subscription ${SUBSCRIPTION}
az account list -o table
# Get the name of the AG
echo "RG = ${RG}"
AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "AG = ${AG}"
# Get the AG backend pool name
BP=$(az network application-gateway address-pool list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $1 }')
echo "Backend pool = ${BP}"
# Get the frontendip of the load balancer
LB=$(az network lb list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
LBFEIP=$(az network lb frontend-ip list --lb-name ${LB} --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "Load balancer = ${LB}"
echo "Frontend ip LB = ${LBFEIP}"
# Update the backend pool of the AG with the frontend ip of the loadbalancer
echo "Updating Backend address pool of AG ${AG}"
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
# Update http settings
echo "Updating HTTP settings of AG ${AG}"
AG_HTS=$(az network application-gateway http-settings list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $2 }')
az network application-gateway http-settings update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HTS} --host-name-from-backend-pool true
# Update health probe
echo "Updating Health probe of AG ${AG}"
AG_HP=$(az network application-gateway probe list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $4 }')
az network application-gateway probe update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HP} --host '' --host-name-from-http-settings true
This script works fine running locally from my laptop but via the azure devops release pipeline I get the error:
ERROR: az network application-gateway address-pool list: error: argument --gateway-name: expected one argument
Somehow it cannot get the application gateway name when the script is running through the release pipeline.
Again, when running this script locally it works fine. Anyoone an idea of what I maybe missing here or can try?
I created the script on WSL Ubuntu and used a ubuntu hosted agent to publish the artifacts and also use a hosted ubuntu agent to deploy the script.
azure azure-devops terraform azure-cli
add a comment |
up vote
0
down vote
favorite
I deployed some infra using Terraform, including an application gateway. Unfortunately not all settings can be set/updated with terraform. SO I have a shell script that updates the application gateway.
#!/bin/bash
SP_ID=${1}
SP_SECRET=${2}
TENANT_ID=${3}
SUBSCRIPTION=${4}
RG=${5}
az login --service-principal -u ${SP_ID} -p ${SP_SECRET} -t ${TENANT_ID}
az account set --subscription ${SUBSCRIPTION}
az account list -o table
# Get the name of the AG
echo "RG = ${RG}"
AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "AG = ${AG}"
# Get the AG backend pool name
BP=$(az network application-gateway address-pool list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $1 }')
echo "Backend pool = ${BP}"
# Get the frontendip of the load balancer
LB=$(az network lb list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
LBFEIP=$(az network lb frontend-ip list --lb-name ${LB} --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "Load balancer = ${LB}"
echo "Frontend ip LB = ${LBFEIP}"
# Update the backend pool of the AG with the frontend ip of the loadbalancer
echo "Updating Backend address pool of AG ${AG}"
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
# Update http settings
echo "Updating HTTP settings of AG ${AG}"
AG_HTS=$(az network application-gateway http-settings list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $2 }')
az network application-gateway http-settings update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HTS} --host-name-from-backend-pool true
# Update health probe
echo "Updating Health probe of AG ${AG}"
AG_HP=$(az network application-gateway probe list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $4 }')
az network application-gateway probe update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HP} --host '' --host-name-from-http-settings true
This script works fine running locally from my laptop but via the azure devops release pipeline I get the error:
ERROR: az network application-gateway address-pool list: error: argument --gateway-name: expected one argument
Somehow it cannot get the application gateway name when the script is running through the release pipeline.
Again, when running this script locally it works fine. Anyoone an idea of what I maybe missing here or can try?
I created the script on WSL Ubuntu and used a ubuntu hosted agent to publish the artifacts and also use a hosted ubuntu agent to deploy the script.
azure azure-devops terraform azure-cli
What is the output of the line above where you echo the result ofAG
? Also you seem to either have a copy-paste mistake on the line that's erroring or you are actually running... -- resource-group...
instead of... --resource-group...
(note the whitespace) which is likely to cause you issues.
– ydaetskcoR
7 hours ago
The echo doesn't give any value for AG, so somehow it doesn't get the AG name. Oh sorry, that was a copy paste mistake. The error is on this command:az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
. But that is just because somehow this doesn't work:AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
– bram
6 hours ago
I think I know what the problem is already... going to try it right now. But I think it because the output is json and not table.
– bram
6 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I deployed some infra using Terraform, including an application gateway. Unfortunately not all settings can be set/updated with terraform. SO I have a shell script that updates the application gateway.
#!/bin/bash
SP_ID=${1}
SP_SECRET=${2}
TENANT_ID=${3}
SUBSCRIPTION=${4}
RG=${5}
az login --service-principal -u ${SP_ID} -p ${SP_SECRET} -t ${TENANT_ID}
az account set --subscription ${SUBSCRIPTION}
az account list -o table
# Get the name of the AG
echo "RG = ${RG}"
AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "AG = ${AG}"
# Get the AG backend pool name
BP=$(az network application-gateway address-pool list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $1 }')
echo "Backend pool = ${BP}"
# Get the frontendip of the load balancer
LB=$(az network lb list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
LBFEIP=$(az network lb frontend-ip list --lb-name ${LB} --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "Load balancer = ${LB}"
echo "Frontend ip LB = ${LBFEIP}"
# Update the backend pool of the AG with the frontend ip of the loadbalancer
echo "Updating Backend address pool of AG ${AG}"
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
# Update http settings
echo "Updating HTTP settings of AG ${AG}"
AG_HTS=$(az network application-gateway http-settings list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $2 }')
az network application-gateway http-settings update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HTS} --host-name-from-backend-pool true
# Update health probe
echo "Updating Health probe of AG ${AG}"
AG_HP=$(az network application-gateway probe list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $4 }')
az network application-gateway probe update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HP} --host '' --host-name-from-http-settings true
This script works fine running locally from my laptop but via the azure devops release pipeline I get the error:
ERROR: az network application-gateway address-pool list: error: argument --gateway-name: expected one argument
Somehow it cannot get the application gateway name when the script is running through the release pipeline.
Again, when running this script locally it works fine. Anyoone an idea of what I maybe missing here or can try?
I created the script on WSL Ubuntu and used a ubuntu hosted agent to publish the artifacts and also use a hosted ubuntu agent to deploy the script.
azure azure-devops terraform azure-cli
I deployed some infra using Terraform, including an application gateway. Unfortunately not all settings can be set/updated with terraform. SO I have a shell script that updates the application gateway.
#!/bin/bash
SP_ID=${1}
SP_SECRET=${2}
TENANT_ID=${3}
SUBSCRIPTION=${4}
RG=${5}
az login --service-principal -u ${SP_ID} -p ${SP_SECRET} -t ${TENANT_ID}
az account set --subscription ${SUBSCRIPTION}
az account list -o table
# Get the name of the AG
echo "RG = ${RG}"
AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "AG = ${AG}"
# Get the AG backend pool name
BP=$(az network application-gateway address-pool list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $1 }')
echo "Backend pool = ${BP}"
# Get the frontendip of the load balancer
LB=$(az network lb list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
LBFEIP=$(az network lb frontend-ip list --lb-name ${LB} --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
echo "Load balancer = ${LB}"
echo "Frontend ip LB = ${LBFEIP}"
# Update the backend pool of the AG with the frontend ip of the loadbalancer
echo "Updating Backend address pool of AG ${AG}"
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
# Update http settings
echo "Updating HTTP settings of AG ${AG}"
AG_HTS=$(az network application-gateway http-settings list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $2 }')
az network application-gateway http-settings update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HTS} --host-name-from-backend-pool true
# Update health probe
echo "Updating Health probe of AG ${AG}"
AG_HP=$(az network application-gateway probe list --resource-group ${RG} --gateway-name ${AG} | tail -n 1 | awk '{ print $4 }')
az network application-gateway probe update --resource-group ${RG} --gateway-name ${AG} --name ${AG_HP} --host '' --host-name-from-http-settings true
This script works fine running locally from my laptop but via the azure devops release pipeline I get the error:
ERROR: az network application-gateway address-pool list: error: argument --gateway-name: expected one argument
Somehow it cannot get the application gateway name when the script is running through the release pipeline.
Again, when running this script locally it works fine. Anyoone an idea of what I maybe missing here or can try?
I created the script on WSL Ubuntu and used a ubuntu hosted agent to publish the artifacts and also use a hosted ubuntu agent to deploy the script.
azure azure-devops terraform azure-cli
azure azure-devops terraform azure-cli
edited 6 hours ago
asked 7 hours ago
bram
6610
6610
What is the output of the line above where you echo the result ofAG
? Also you seem to either have a copy-paste mistake on the line that's erroring or you are actually running... -- resource-group...
instead of... --resource-group...
(note the whitespace) which is likely to cause you issues.
– ydaetskcoR
7 hours ago
The echo doesn't give any value for AG, so somehow it doesn't get the AG name. Oh sorry, that was a copy paste mistake. The error is on this command:az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
. But that is just because somehow this doesn't work:AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
– bram
6 hours ago
I think I know what the problem is already... going to try it right now. But I think it because the output is json and not table.
– bram
6 hours ago
add a comment |
What is the output of the line above where you echo the result ofAG
? Also you seem to either have a copy-paste mistake on the line that's erroring or you are actually running... -- resource-group...
instead of... --resource-group...
(note the whitespace) which is likely to cause you issues.
– ydaetskcoR
7 hours ago
The echo doesn't give any value for AG, so somehow it doesn't get the AG name. Oh sorry, that was a copy paste mistake. The error is on this command:az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
. But that is just because somehow this doesn't work:AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
– bram
6 hours ago
I think I know what the problem is already... going to try it right now. But I think it because the output is json and not table.
– bram
6 hours ago
What is the output of the line above where you echo the result of
AG
? Also you seem to either have a copy-paste mistake on the line that's erroring or you are actually running ... -- resource-group...
instead of ... --resource-group...
(note the whitespace) which is likely to cause you issues.– ydaetskcoR
7 hours ago
What is the output of the line above where you echo the result of
AG
? Also you seem to either have a copy-paste mistake on the line that's erroring or you are actually running ... -- resource-group...
instead of ... --resource-group...
(note the whitespace) which is likely to cause you issues.– ydaetskcoR
7 hours ago
The echo doesn't give any value for AG, so somehow it doesn't get the AG name. Oh sorry, that was a copy paste mistake. The error is on this command:
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
. But that is just because somehow this doesn't work: AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
– bram
6 hours ago
The echo doesn't give any value for AG, so somehow it doesn't get the AG name. Oh sorry, that was a copy paste mistake. The error is on this command:
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
. But that is just because somehow this doesn't work: AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
– bram
6 hours ago
I think I know what the problem is already... going to try it right now. But I think it because the output is json and not table.
– bram
6 hours ago
I think I know what the problem is already... going to try it right now. But I think it because the output is json and not table.
– bram
6 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266028%2fazure-devops-hosted-ubuntu-agent-issue-updating-application-gateway%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What is the output of the line above where you echo the result of
AG
? Also you seem to either have a copy-paste mistake on the line that's erroring or you are actually running... -- resource-group...
instead of... --resource-group...
(note the whitespace) which is likely to cause you issues.– ydaetskcoR
7 hours ago
The echo doesn't give any value for AG, so somehow it doesn't get the AG name. Oh sorry, that was a copy paste mistake. The error is on this command:
az network application-gateway address-pool update --gateway-name $AG --resource-group $RG --name $BP --servers ${LBFEIP}
. But that is just because somehow this doesn't work:AG=$(az network application-gateway list --resource-group ${RG} | tail -n 1 | awk '{ print $2 }')
– bram
6 hours ago
I think I know what the problem is already... going to try it right now. But I think it because the output is json and not table.
– bram
6 hours ago