Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.2k stars 742 forks source link

Cannot set BackendIPConfigurations as Virtual mahine on ApplicationGateway through bicep #6396

Closed kgundraju closed 2 years ago

kgundraju commented 2 years ago

Bicep version v0.4.1318 Describe the bug We are unable to add Virtual machine as backendpool to the Application gateway through bicep IaC.

In Microsoft document we could see that there are only two placeholders for IPAddress and FQDN but the requirement is to add virtual machine as backendpool. Options available in portal: image

Options available in Bicep template: https://docs.microsoft.com/en-us/azure/templates/microsoft.network/applicationgateways?tabs=bicep

To Reproduce The below code is inspiration from https://github.com/Azure/azure-rest-api-specs/issues/7475

backendAddressPools: [
      {
        name: 'backendpool'
        properties: {
          backendAddresses: [
            {
              'id': networkInterfaceID
            } 
          ]          
        }
      }
    ]

this code is giving below error.

Error:

The property "id" is not allowed on objects of type "ApplicationGatewayBackendAddress". Permissible properties include "fqdn", "ipAddress". If this is an inaccuracy in the documentation, please report it to the Bicep Team.

Additional context We are stuck here and there is no proper documentation is available on the same.

alex-frankel commented 2 years ago

Is this a warning or an error? If it is a warning, have you tried deploying the code and did it deploy successfully?

It's possible the type definition for this resource type is not complete/accurate, but that should be non-blocking.

kgundraju commented 2 years ago

This particular setting should come from NIC, below scripts works fine.

resource networkSecurityGroupResource 'Microsoft.Network/networkSecurityGroups@2020-11-01' existing = { name: networkSecurityGroupName }

resource virtualNetworkResource 'Microsoft.Network/virtualNetworks@2020-11-01' existing = { name: sonarVirtualNetworkName }

resource publicIPAddressResource 'Microsoft.Network/publicIPAddresses@2020-11-01' existing = { name: publicIPAddressName } var appGwId = resourceId('Microsoft.Network/applicationGateways', appGatewayName)

resource networkInterfaceResource 'Microsoft.Network/networkInterfaces@2020-11-01' = { name: networkInterfaceName location: location tags: { Environment: environment sonarqube: tags } properties: { ipConfigurations: [ { name: 'ipconfig1' properties: { privateIPAllocationMethod: 'Dynamic' publicIPAddress: { id: publicIPAddressResource.id } subnet: { id: '${virtualNetworkResource.id}/subnets/${subnetName}' } applicationGatewayBackendAddressPools: [ { id: '${appGwId}/backendAddressPools/backendpool'
} ] primary: true privateIPAddressVersion: 'IPv4' } } ] enableAcceleratedNetworking: false enableIPForwarding: false networkSecurityGroup: { id: networkSecurityGroupResource.id } } }