Application Gateway Deployment not working with SSL Certificate and HTTPS Listener
Bicep version Bicep CLI version 0.25.3 (862708594a)
Describe the bug When defining a httpListeners in the namespace of Microsoft.Network/applicationGateways@2023-02-01 (I already tried different versions) then BICEP hangs. No error, it just stays there doing nothing in the CLI. When I create a HTTP Listener it deploys immediately.
To Reproduce Use this template as a reference:
param location string = resourceGroup().location
param appGatewayName string
param subnetId string // The Subnet Resource ID where the Application Gateway will be deployed
param userAssignedIdentityId string // The User Assigned Identity Resource ID that will be used to manage the Application Gateway
// Variables
var appGatewayId = '/subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Network/applicationGateways/${appGatewayName}'
// Define the public IP address for the Application Gateway
resource publicIp 'Microsoft.Network/publicIPAddresses@2023-04-01' = {
name: 'pip-${appGatewayName}'
location: location
sku: {
name: 'Standard'
}
properties: {
publicIPAddressVersion: 'IPv4'
publicIPAllocationMethod: 'Static'
}
}
// Define the Application Gateway with WAF v2
resource appGateway 'Microsoft.Network/applicationGateways@2023-02-01' = {
name: appGatewayName
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${userAssignedIdentityId}': {}
}
}
properties: {
sku: {
name: 'WAF_v2'
tier: 'WAF_v2'
}
autoscaleConfiguration: {
minCapacity: 1
maxCapacity: 2
}
gatewayIPConfigurations: [
{
name: 'appGatewayIpConfig'
properties: {
subnet: {
id: subnetId
}
}
}
]
frontendIPConfigurations: [
{
name: 'appGatewayFrontendIp'
properties: {
publicIPAddress: {
id: publicIp.id
}
}
}
]
frontendPorts: [
// {
// name: 'appGatewayFrontendPortHttp'
// properties: {
// port: 80
// }
// }
{
name: 'appGatewayFrontendPortHttps'
properties: {
port: 443
}
}
]
backendAddressPools: [
{
name: 'appGatewayBackendPool'
properties: {
backendAddresses: []
}
}
// {
// name: 'appGatewayNonProdBackendPool'
// properties: {
// backendAddresses: [
// {
// ipAddress: '1.1.1.1'
// }
// ]
// }
// }
]
backendHttpSettingsCollection: [
{
name: 'appGatewayBackendHttpSettings'
properties: {
port: 443
protocol: 'Https'
cookieBasedAffinity: 'Disabled'
hostName: 'blabla.com'
pickHostNameFromBackendAddress: false
path: '/'
requestTimeout: 20
probe: {
id: '${appGatewayId}/probes/appGatewayHealthProbe'
}
}
}
]
sslCertificates: [
{
name: 'SECRETNAME'
properties: {
keyVaultSecretId: 'https://KVNAME${environment().suffixes.keyvaultDns}/secrets/SECRETNAME'
}
}
]
httpListeners: [
// {
// name: 'appGatewayHttpListener'
// properties: {
// frontendIPConfiguration: {
// id: '${appGatewayId}/frontendIPConfigurations/appGatewayFrontendIp'
// }
// frontendPort: {
// id: '${appGatewayId}/frontendPorts/appGatewayFrontendPortHttp'
// }
// protocol: 'Http'
// }
// }
{
name: 'appGatewayHttpsListener'
properties: {
frontendIPConfiguration: {
id: '${appGatewayId}/frontendIPConfigurations/appGatewayFrontendIp'
}
frontendPort: {
id: '${appGatewayId}/frontendPorts/appGatewayFrontendPortHttps'
}
protocol: 'Https'
sslCertificate: {
id: '${appGatewayId}/sslCertificates/SSLCERTNAME'
}
hostNames: []
requireServerNameIndication: false
customErrorConfigurations: []
}
}
]
requestRoutingRules: [
{
name: 'appGatewayRuleRoot'
properties: {
ruleType: 'Basic'
priority: 1
httpListener: {
id: '${appGatewayId}/httpListeners/appGatewayHttpsListener'
}
backendAddressPool: {
id: '${appGatewayId}/backendAddressPools/appGatewayBackendPool'
}
backendHttpSettings: {
id: '${appGatewayId}/backendHttpSettingsCollection/appGatewayBackendHttpSettings'
}
}
}
]
probes: [
{
name: 'appGatewayHealthProbe'
id: '${appGatewayId}/probes/appGatewayHealthProbe'
properties: {
protocol: 'Https'
host: 'blabla.com'
port: 443
path: '/echo/resource'
interval: 30
timeout: 30
unhealthyThreshold: 3
pickHostNameFromBackendHttpSettings: false
minServers: 0
match: {}
}
}
]
webApplicationFirewallConfiguration: {
enabled: true
firewallMode: 'Prevention'
ruleSetType: 'OWASP'
ruleSetVersion: '3.2'
}
}
}
Additional context When exporting the template and deploying it back to the same Resource Group the same behaviour occurs.
Some additional context:
When I am out commenting this part of the BICEP template:
sslCertificate: {
id: '${appGatewayId}/sslCertificates/SSLCERTNAME'
}
The deployment starts, however without this part it will result in an error because the protocol is HTTPS and it expects a SSL Certificate. So it seems to be related to the reference of the sslCertificate?
This link also explains more about it and I am exactly following the structure/link references as described on the page: https://learn.microsoft.com/en-us/azure/application-gateway/ssl-certificate-management?WT.mc_id=Portal-Microsoft_Azure_HybridNetworking
Also adding the sslCertificate based on 'data' and 'password' properties does not work.
It seems my references to the Application Gateway involving:
- id: '${appGatewayId}/probes/appGatewayHealthProbe'
Was not correct. It should be:
- id: resourceId('Microsoft.Network/applicationGateways/probes', appGatewayName, 'appGatewayHealthProbe')
This resolved my issue with the above. My apologies for any inconvenience.