如何在az network application-gateway rule create命令中指定多个url-path-map
解决Azure应用网关规则关联多个URL路径映射的问题
Azure CLI的az network application-gateway rule create命令不支持在单个路由规则中指定多个url-path-map——每个PathBasedRouting类型的规则只能关联一个URL路径映射。
要实现关联多个url-path-map的需求,你需要为每个URL路径映射创建独立的路由规则,并为每个规则设置唯一的优先级(优先级数值越小,规则匹配优先级越高)。
示例命令
以下是针对你的两个URL路径映射MyPathMap2和MyPathMap3创建对应规则的具体命令:
为MyPathMap2创建路由规则
az network application-gateway rule create \ --gateway-name 你的应用网关名称 \ --name Rule-MyPathMap2 \ --resource-group 你的资源组名称 \ --address-pool 你的地址池名称 \ --http-listener 你的HTTP监听器名称 \ --http-settings 你的HTTP设置名称 \ --rule-type PathBasedRouting \ --url-path-map MyPathMap2 \ --priority 100
为MyPathMap3创建路由规则
az network application-gateway rule create \ --gateway-name 你的应用网关名称 \ --name Rule-MyPathMap3 \ --resource-group 你的资源组名称 \ --address-pool 你的地址池名称 \ --http-listener 你的HTTP监听器名称 \ --http-settings 你的HTTP设置名称 \ --rule-type PathBasedRouting \ --url-path-map MyPathMap3 \ --priority 200
注意事项
- 必须确保每个规则的
--priority参数值唯一,否则命令会执行失败。 - 请求匹配时,会优先触发优先级数值更小的规则,可根据业务需求调整优先级顺序。
内容的提问来源于stack exchange,提问作者juanito
相关产品推荐
相关产品推荐

