Unable to create a listener in the App gateway from powershell

MoTaar 310 Reputation points
2023-10-30T22:50:27.8533333+00:00

Hello,

I am tring to add listeners using powershell but I am stuck in the step of getting Ip info as it was already created. Please see the code I use:

#Create IP Config and front-end port
$pip = Get-AzPublicIPAddress -ResourceGroupName APPGATEWAY-RG -Name "appGwPublicFrontendIpIPv4"
$fipconfig = New-AzApplicationGatewayFrontendIPConfig `
 -Name myAGFrontendIPConfig `
 -PublicIPAddress $pip
# Save the application gateway with the configuration changes
Set-AzApplicationGateway -ApplicationGateway $getgw
$frontendportHTTP = New-AzApplicationGatewayFrontendPort ` -Name myfrontendportHTTP ` -Port 80$Appgw = Add-AzApplicationGatewayHttpListener `  -ApplicationGateway $getgw `  -Name "QAwebCandidateListenersHttp" `  -Protocol "Http" `  -FrontendIpConfiguration $fipconfig `  -FrontendPort $frontendportHTTP `  -HostName "irap-qacandidat.epsi-inc.com"# Save the application gateway with the configuration changesSet-AzApplicationGateway -ApplicationGateway $getgw

and here is the error I am getting:

Set-AzApplicationGateway : Resource /subscriptions/**********/resourceGroups/***/pr
oviders/Microsoft.Network/applicationGateways/*******/frontendIPConfigurations/*****
referenced by resource /subscriptions/****/resourceGroups/*****/providers/Micro
soft.Network/applicationGateways/*******/httpListeners/******* was not found.
Please make sure that the referenced resource exists, and that both resources are in the same region.
At line:1 char:1
+ Set-AzApplicationGateway -ApplicationGateway $getgw
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzApplicationGateway], CloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.SetAzureApplicationGatewayCommand
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,217 questions
Windows for business | Windows Server | User experience | PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. MoTaar 310 Reputation points
    2023-11-03T12:19:45.8833333+00:00

    Thank for the answer, but it's fine I found the issue, I had to use :

    # Create IP Config and front-end port 
    $pip = Get-AzPublicIPAddress -ResourceGroupName APPGATEWAY-RG -Name "appGwPublicFrontendIpIPv4" 
    $fipconfig = ADD-AzApplicationGatewayFrontendIPConfig `  
    -Name myAGFrontendIPConfig `  
    -PublicIPAddress $pip 
    # Save the application gateway with the configuration changes 
    Set-AzApplicationGateway -ApplicationGateway $getgw 
    $frontendportHTTP = Add-AzApplicationGatewayFrontendPort ` 
    -Name myfrontendportHTTP ` 
    -Port 80
    $Appgw = Add-AzApplicationGatewayHttpListener `  
    -ApplicationGateway $getgw `  
    -Name "QAwebCandidateListenersHttp" `  
    -Protocol "Http" `  
    -FrontendIpConfiguration $fipconfig `  
    -FrontendPort $frontendportHTTP `  
    -HostName "irap-qacandidat.epsi-inc.com"
    # Save the application gateway with the configuration changes
    Set-AzApplicationGateway -ApplicationGateway $getg
    

    instead of the first one


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.