如何在C#中为Azure应用程序网关创建基于路径的路由规则?
通过Azure Portal,我使用基于路径的路由手动创建了一个应用程序网关。现在,我需要在C#中实现这一点的自动化。我似乎找不到任何方法来创建基于路径的路由规则。我正在使用Microsoft.Azure.Management.Fluent软件包。我错过了什么 如果Fluent API不支持这一点,是否有REST替代方案 例: 我可以在Microsoft.Azure.Management.Fluent包中找到,但找不到配置它的方法。github中也有与此相关的内容 但它肯定可以使用包创建具有基于路径的路由设置的如何在C#中为Azure应用程序网关创建基于路径的路由规则?,c#,azure,azure-application-gateway,C#,Azure,Azure Application Gateway,通过Azure Portal,我使用基于路径的路由手动创建了一个应用程序网关。现在,我需要在C#中实现这一点的自动化。我似乎找不到任何方法来创建基于路径的路由规则。我正在使用Microsoft.Azure.Management.Fluent软件包。我错过了什么 如果Fluent API不支持这一点,是否有REST替代方案 例: 我可以在Microsoft.Azure.Management.Fluent包中找到,但找不到配置它的方法。github中也有与此相关的内容 但它肯定可以使用包创建具有基于
应用程序网关
以下是一个例子:
ApplicationGateway gateway = new ApplicationGateway();
//configure thepath-based routing.
ApplicationGatewayRequestRoutingRule r = new ApplicationGatewayRequestRoutingRule();
r.RuleType = ApplicationGatewayRequestRoutingRuleType.PathBasedRouting;
gateway.RequestRoutingRules.Add(r);
//configure other settings.
//gateway.Location = "xxx";
gateway.Validate();
//create the gateway.
NetworkManagementClient networkManagementClient = new NetworkManagementClient(your_credential);
networkManagementClient.ApplicationGateways.CreateOrUpdate("resource group name", "application gateway name", gateway);
参考代码示例:和
有关api,请参阅。在请求主体中,它定义了基于路径的路由设置。在Azure中配置东西的方法有很多。再次感谢。这对我有用。
ApplicationGateway gateway = new ApplicationGateway();
//configure thepath-based routing.
ApplicationGatewayRequestRoutingRule r = new ApplicationGatewayRequestRoutingRule();
r.RuleType = ApplicationGatewayRequestRoutingRuleType.PathBasedRouting;
gateway.RequestRoutingRules.Add(r);
//configure other settings.
//gateway.Location = "xxx";
gateway.Validate();
//create the gateway.
NetworkManagementClient networkManagementClient = new NetworkManagementClient(your_credential);
networkManagementClient.ApplicationGateways.CreateOrUpdate("resource group name", "application gateway name", gateway);