With Azure Portal I have manually created an Application Gateway using path-based routing. Now I need to automate this in C#. I can't seem to find any way to create a path-based routing rule. I'm using the Microsoft.Azure.Management.Fluent package. What am I missing?
If this isn't supported through the Fluent API, is there a REST alternative?
Ex:
var appGw = Azure.ApplicationGateways.Define(AppGwName)
.WithRegion(Region)
.WithExistingResourceGroup(resourceGroup)
.DefineRequestRoutingRule("default")
// Now what?
I can find the path-based routing settings in the Microsoft.Azure.Management.Fluent
package, but cannot find a way to configure it. And there is an issue related to this in github.
But it can definitely use the Microsoft.Azure.Management.Network package to create the Application Gateway
with path-based routing settings
.
Here is an example:
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);
The reference code example: here and here .
For api, you can refer to Create Application Gateway . And in the request body, it defines the path-based routing settings
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.