Search code examples
azureazure-cli

How to specify more than 1 url-path-map in the command of az network application-gateway rule create


The command in question is this:

az network application-gateway rule create --gateway-name --name --resource-group [--address-pool] [--http-listener] [--http-settings] [--no-wait {0, 1, f, false, n, no, t, true, y, yes}] [--priority] [--redirect-config] [--rewrite-rule-set] [--rule-type {Basic, PathBasedRouting}] [--url-path-map]

I have 2 url-path-map named MyPathMap2 and MyPathMap3.

But if I want it to have 2 or more paths I do not know how to modify the command so that it accepts more than 1 path-map.

According to the documentation, I should use the parameter --rule-type PathBasedRouting, then to create the rule with 1 single path-map I use the command:

az network application-gateway rule create --gateway-name --name --resource-group --address-pool --http-listener --http-settings --rule-type PathBasedRouting --url-path-map MyPathMap2 --priority

Solution

  • Want it to have 2 or more paths I do not know how to modify the command so that it accepts more than 1 path-map.

    AFAIK, we can't pass the 2 URL path-map while creating an application gateway network rule.

    You can follow this MS-Document to create URL path map to add in the rule name.

    You can create a single Url path map while creating an application gateway rule.

    Command:

    I have created a rule for a single URL path map with the below command.

    az network application-gateway rule create \
      --gateway-name myAppGateway \
      --name rule2 \
      --resource-group myResourceGroupAG \
      --http-listener backendListener \
      --rule-type PathBasedRouting \
      --url-path-map myPathMap \
      --address-pool appGatewayBackendPool \
      --priority 200
    

    Output: enter image description here

    If you need to add the Url path map with the same rule name, you can use the command below.

    Command:

    az network application-gateway url-path-map rule create \
      --gateway-name myAppGateway \
      --name videoPathRule \
      --resource-group myResourceGroupAG \
      --path-map-name myPathMap \
      --paths /video/* \
      --address-pool videoBackendPool \
      --http-settings appGatewayBackendHttpSettings
    

    Output: enter image description here

    Portal: enter image description here