Open
Description
openedon Feb 17, 2022
Bicep version
Bicep CLI version 0.4.1272
Describe the bug
-
On converting the Application Gateway ARM template to BICEP using az bicep decompile the template gets converted with the error "Expression is referring its own declaration"
-
In the below piece of code for Properties.httpListeners & Properties.requestRoutingRules we need to refer to the appgateway resource that was created. Example for frontendIPConfiguration but these line errors out with above message
-
App gateway need at least httpListener defined hence not able to create app gateway using BICEP
-
Below is an sample piece of code
param applicationGateways_agw_aks_test_scus_001_name string = 'agw-sample-dev-scus-001' param virtualNetworks_vnet_dev_scus_001_externalid string = '/subscriptions/<SUB_ID>/resourceGroups/<RESOURCE_NAME>/providers/Microsoft.Network/virtualNetworks/<VNET_NAME>' param publicIPAddresses_pip_mw_dev_scus_001_externalid string = '/subscriptions/<SUB_ID>/resourceGroups/<RESOURCE_NAME>/providers/Microsoft.Network/publicIPAddresses/<PUBLIC_IP_NAME>' resource applicationGateways_agw_aks_test_scus_001_name_resource 'Microsoft.Network/applicationGateways@2020-11-01' = { name: applicationGateways_agw_aks_test_scus_001_name location: 'southcentralus' properties: { sku: { name: 'Standard_v2' tier: 'Standard_v2' capacity: 2 } httpListeners: [ { name: 'appGatewayHttpListener' properties: { frontendIPConfiguration: { id: '${applicationGateways_agw_aks_test_scus_001_name_resource.id}/frontendIPConfigurations/appGatewayFrontendIP' } frontendPort: { id: '${applicationGateways_agw_aks_test_scus_001_name_resource.id}/frontendPorts/appGatewayFrontendPort' } protocol: 'Http' hostNames: [] requireServerNameIndication: false } } ] requestRoutingRules: [ { name: 'rule1' properties: { ruleType: 'Basic' httpListener: { id: '${applicationGateways_agw_aks_test_scus_001_name_resource.id}/httpListeners/appGatewayHttpListener' } backendAddressPool: { id: '${applicationGateways_agw_aks_test_scus_001_name_resource.id}/backendAddressPools/appGatewayBackendPool' } backendHttpSettings: { id: '${applicationGateways_agw_aks_test_scus_001_name_resource.id}/backendHttpSettingsCollection/appGatewayBackendHttpSettings' } } } ] } }
To Reproduce
- Open the powershell terminal and run az login command and set the subscription scope
- Execute below command to create a App Gateway resource
az network application-gateway create -n "<GATEWAY_NAME>" -l "<AZURE_LOCATION>" -g "<RESOURCE_GROUP>" --sku Standard_v2 --public-ip-address "<PUBLIC_IP_ADDRESS>" --vnet-name "<VNET_NAME>" --subnet "<SUBNET_NAME>"
- Once the resource is created, go to Automation -> Export and export the ARM template json
- Convert the ARM json to BICEP using below command
az bicep decompile --file <FILE_NAME>.json
- On the BICEP file there will be an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment