AzureNatGatewayExtensions Methods
ClassMethods2 members
Provides extension methods for adding Azure NAT Gateway resources to the application model.
AddNatGateway(IDistributedApplicationBuilder, string)Section titled AddNatGateway(IDistributedApplicationBuilder, string)extensionIResourceBuilder<AzureNatGatewayResource> Adds an Azure NAT Gateway resource to the application model.
public static class AzureNatGatewayExtensions{ public static IResourceBuilder<AzureNatGatewayResource> AddNatGateway( this IDistributedApplicationBuilder builder, string name) { // ... }}Parameters
builderIDistributedApplicationBuilderThe builder for the distributed application.namestringThe name of the Azure NAT Gateway resource.Returns
IResourceBuilder<AzureNatGatewayResource>A reference to the ApplicationModel.IResourceBuilder`1.Remarks
The NAT Gateway is created with Standard SKU. If no Public IP Address is explicitly associated via
AzureNatGatewayExtensions.WithPublicIPAddress, a Public IP Address is automatically created in the NAT Gateway's bicep module with Standard SKU and Static allocation. Examples
This example creates a NAT Gateway and associates it with a subnet:
var natGateway = builder.AddNatGateway("nat");
var vnet = builder.AddAzureVirtualNetwork("vnet");var subnet = vnet.AddSubnet("aca-subnet", "10.0.0.0/23") .WithNatGateway(natGateway);WithPublicIPAddress(IResourceBuilder<AzureNatGatewayResource>, IResourceBuilder<AzurePublicIPAddressResource>)Section titled WithPublicIPAddress(IResourceBuilder<AzureNatGatewayResource>, IResourceBuilder<AzurePublicIPAddressResource>)extensionIResourceBuilder<AzureNatGatewayResource> Associates an explicit Public IP Address resource with the NAT Gateway.
public static class AzureNatGatewayExtensions{ public static IResourceBuilder<AzureNatGatewayResource> WithPublicIPAddress( this IResourceBuilder<AzureNatGatewayResource> builder, IResourceBuilder<AzurePublicIPAddressResource> publicIPAddress) { // ... }}Parameters
builderIResourceBuilder<AzureNatGatewayResource>The NAT Gateway resource builder.publicIPAddressIResourceBuilder<AzurePublicIPAddressResource>The Public IP Address resource to associate.Returns
IResourceBuilder<AzureNatGatewayResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.Remarks
When an explicit Public IP Address is provided, the NAT Gateway will not auto-create one.
Examples
This example creates a NAT Gateway with an explicit Public IP:
var pip = builder.AddPublicIPAddress("nat-pip");var natGateway = builder.AddNatGateway("nat") .WithPublicIPAddress(pip);