Coder Perfect

Getting ResourceId error (redirectConfigurations) while deploying AppGate with bicep

Problem

redirectConfigurations piece of code:


 {
        name: 'SiteRoutingRule_404'
        properties: {
          redirectType: 'Permanent'
          targetUrl: ******
          includePath: false
          includeQueryString: false
          pathRules: [
            {
              id: resourceId('Microsoft.Network/applicationGateways/urlPathMaps/pathRules', applicationGateways_name_var, 'SiteRoutingRule/pathRules/404')
            }
          ]
        }
      }



error:

{
    "status": "Failed",
    "error": {
        "code": "InvalidTemplate",
        "message": "Unable to process template language expressions for resource '/subscriptions/*******************/resourceGroups/RG/providers/Microsoft.Network/applicationGateways/AppGW' at line '1' and column '2689'. 
          'Unable to evaluate template language function 'resourceId': function requires exactly one multi-segmented argument which must be resource type including resource provider namespace.
      Current function arguments 'Microsoft.Network/applicationGateways/urlPathMaps/pathRules,AppGW,DemoTestRoutingRule/pathRules/404'. 
           Please see https://aka.ms/arm-template-expressions/#resourceid for usage details.'",
        "additionalInfo": [
            {
                "type": "TemplateViolation",
                "info": {
                    "lineNumber": 1,
                    "linePosition": 2689,
                    "path": ""
                }
            }
        ]
    }
}

I’m not sure what I’m missing in pathRules’ ResourceId. This code works for the Arm Template, but it doesn’t work for the Bicep Template. I couldn’t find a good example of how to add the pathRules resourceId.

Asked by Abkade

Post is based on https://stackoverflow.com/questions/70466962/getting-resourceid-error-redirectconfigurations-while-deploying-appgate-with-b