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.










share|improve this question
























  • 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















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.










share|improve this question
























  • 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













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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 6 hours ago

























asked 7 hours ago









bram

6610




6610












  • 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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




















































































Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?