agent: |
I5IxxAtcEaeWP7QC0DDzGet Listeners Without HTTPS Redirection in Azure Application Gateway
Get Listeners Without HTTPS Redirection in Azure Application Gateway
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
This task involves identifying and retrieving a list of all the listeners configured in an Azure Application Gateway that are set up without HTTPS redirection. It focuses on isolating listeners that directly handle incoming traffic without redirecting to HTTPS, essential for managing secure and non-secure traffic routing rules.
inputs
outputs
from azure.identity import DefaultAzureCredential
from azure.mgmt.network import NetworkManagementClient
from azure.core.exceptions import HttpResponseError
# Initialize Azure credentials and NetworkManagementClient
credential = DefaultAzureCredential()
network_client = NetworkManagementClient(credential, subscription_id)
try:
app_gateways = list(network_client.application_gateways.list_all())
if not app_gateways:
print("No application gateways found in the subscription.")
else:
total_listeners = 0
listeners_without_https = []
for app_gw in app_gateways:
if app_gw.http_listeners:
for listener in app_gw.http_listeners:
total_listeners += 1
if listener.protocol != "Https":
listeners_without_https.append(listener)
print(f"Listener without HTTPS found: {listener.name} in Application Gateway: {app_gw.name}")
print(f"Processed {len(app_gateways)} Application Gateway(s).")
print(f"Total HTTP listener(s) found: {total_listeners}.")
if not listeners_without_https:
print("All listener(s) are already configured for HTTPS.")
else:
print(f"Found {len(listeners_without_https)} listener(s) without HTTPS out of {total_listeners} total listener(s).")
except HttpResponseError as e:
print(f"An error occurred with the Azure HTTP response: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
context.proceed = False
copied