'ARM template error. A nested resource type must have identical number of segments as its resource name

I am trying to deploy an ARM template to create an azure VM and an azure bastion subnet and I am getting the above error. below is the screenshot of my code for azure bastion. This is the complete error that I am getting,

"Deployment template validation failed: 'The template resource 'AzureBastionSubnet' for type 'Microsoft.Network/virtualNetworks/subnets' at line '231' and column '61' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name."

I am attaching relevant code sec. below

 "apiVersion": "2018-10-01",
            "type": "Microsoft.Network/bastionHosts",
            "name": "[parameters('bastionHostName')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId(parameters('resourceGroup'), 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
            ],
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "IpConf",
                        "properties": {
                            "subnet": {
                                "id": "[resourceId(parameters('resourceGroup'), 'Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'),variables('subnetName'))]"
                            },
                            "publicIPAddress": {
                                "id": "[resourceId(parameters('resourceGroup'), 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
                            }
                        }
                    }
                ]
            }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source