1. Packages
  2. Azure Native v2
  3. API Docs
  4. network
  5. ForwardingRule
These are the docs for Azure Native v2. We recommenend using the latest version, Azure Native v3.
Azure Native v2 v2.90.0 published on Thursday, Mar 27, 2025 by Pulumi

azure-native-v2.network.ForwardingRule

Explore with Pulumi AI

Describes a forwarding rule within a DNS forwarding ruleset. Azure REST API version: 2022-07-01. Prior API version in Azure Native 1.x: 2020-04-01-preview.

Other available API versions: 2023-07-01-preview.

Example Usage

Upsert forwarding rule in a DNS forwarding ruleset

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var forwardingRule = new AzureNative.Network.ForwardingRule("forwardingRule", new()
    {
        DnsForwardingRulesetName = "sampleDnsForwardingRuleset",
        DomainName = "contoso.com.",
        ForwardingRuleName = "sampleForwardingRule",
        ForwardingRuleState = AzureNative.Network.ForwardingRuleState.Enabled,
        Metadata = 
        {
            { "additionalProp1", "value1" },
        },
        ResourceGroupName = "sampleResourceGroup",
        TargetDnsServers = new[]
        {
            new AzureNative.Network.Inputs.TargetDnsServerArgs
            {
                IpAddress = "10.0.0.1",
                Port = 53,
            },
            new AzureNative.Network.Inputs.TargetDnsServerArgs
            {
                IpAddress = "10.0.0.2",
                Port = 53,
            },
        },
    });

});
Copy
package main

import (
	network "github.com/pulumi/pulumi-azure-native-sdk/network/v2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := network.NewForwardingRule(ctx, "forwardingRule", &network.ForwardingRuleArgs{
			DnsForwardingRulesetName: pulumi.String("sampleDnsForwardingRuleset"),
			DomainName:               pulumi.String("contoso.com."),
			ForwardingRuleName:       pulumi.String("sampleForwardingRule"),
			ForwardingRuleState:      pulumi.String(network.ForwardingRuleStateEnabled),
			Metadata: pulumi.StringMap{
				"additionalProp1": pulumi.String("value1"),
			},
			ResourceGroupName: pulumi.String("sampleResourceGroup"),
			TargetDnsServers: network.TargetDnsServerArray{
				&network.TargetDnsServerArgs{
					IpAddress: pulumi.String("10.0.0.1"),
					Port:      pulumi.Int(53),
				},
				&network.TargetDnsServerArgs{
					IpAddress: pulumi.String("10.0.0.2"),
					Port:      pulumi.Int(53),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.ForwardingRule;
import com.pulumi.azurenative.network.ForwardingRuleArgs;
import com.pulumi.azurenative.network.inputs.TargetDnsServerArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var forwardingRule = new ForwardingRule("forwardingRule", ForwardingRuleArgs.builder()
            .dnsForwardingRulesetName("sampleDnsForwardingRuleset")
            .domainName("contoso.com.")
            .forwardingRuleName("sampleForwardingRule")
            .forwardingRuleState("Enabled")
            .metadata(Map.of("additionalProp1", "value1"))
            .resourceGroupName("sampleResourceGroup")
            .targetDnsServers(            
                TargetDnsServerArgs.builder()
                    .ipAddress("10.0.0.1")
                    .port(53)
                    .build(),
                TargetDnsServerArgs.builder()
                    .ipAddress("10.0.0.2")
                    .port(53)
                    .build())
            .build());

    }
}
Copy
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const forwardingRule = new azure_native.network.ForwardingRule("forwardingRule", {
    dnsForwardingRulesetName: "sampleDnsForwardingRuleset",
    domainName: "contoso.com.",
    forwardingRuleName: "sampleForwardingRule",
    forwardingRuleState: azure_native.network.ForwardingRuleState.Enabled,
    metadata: {
        additionalProp1: "value1",
    },
    resourceGroupName: "sampleResourceGroup",
    targetDnsServers: [
        {
            ipAddress: "10.0.0.1",
            port: 53,
        },
        {
            ipAddress: "10.0.0.2",
            port: 53,
        },
    ],
});
Copy
import pulumi
import pulumi_azure_native as azure_native

forwarding_rule = azure_native.network.ForwardingRule("forwardingRule",
    dns_forwarding_ruleset_name="sampleDnsForwardingRuleset",
    domain_name="contoso.com.",
    forwarding_rule_name="sampleForwardingRule",
    forwarding_rule_state=azure_native.network.ForwardingRuleState.ENABLED,
    metadata={
        "additionalProp1": "value1",
    },
    resource_group_name="sampleResourceGroup",
    target_dns_servers=[
        {
            "ip_address": "10.0.0.1",
            "port": 53,
        },
        {
            "ip_address": "10.0.0.2",
            "port": 53,
        },
    ])
Copy
resources:
  forwardingRule:
    type: azure-native:network:ForwardingRule
    properties:
      dnsForwardingRulesetName: sampleDnsForwardingRuleset
      domainName: contoso.com.
      forwardingRuleName: sampleForwardingRule
      forwardingRuleState: Enabled
      metadata:
        additionalProp1: value1
      resourceGroupName: sampleResourceGroup
      targetDnsServers:
        - ipAddress: 10.0.0.1
          port: 53
        - ipAddress: 10.0.0.2
          port: 53
Copy

Create ForwardingRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ForwardingRule(name: string, args: ForwardingRuleArgs, opts?: CustomResourceOptions);
@overload
def ForwardingRule(resource_name: str,
                   args: ForwardingRuleArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def ForwardingRule(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   dns_forwarding_ruleset_name: Optional[str] = None,
                   domain_name: Optional[str] = None,
                   resource_group_name: Optional[str] = None,
                   target_dns_servers: Optional[Sequence[TargetDnsServerArgs]] = None,
                   forwarding_rule_name: Optional[str] = None,
                   forwarding_rule_state: Optional[Union[str, ForwardingRuleState]] = None,
                   metadata: Optional[Mapping[str, str]] = None)
func NewForwardingRule(ctx *Context, name string, args ForwardingRuleArgs, opts ...ResourceOption) (*ForwardingRule, error)
public ForwardingRule(string name, ForwardingRuleArgs args, CustomResourceOptions? opts = null)
public ForwardingRule(String name, ForwardingRuleArgs args)
public ForwardingRule(String name, ForwardingRuleArgs args, CustomResourceOptions options)
type: azure-native:network:ForwardingRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ForwardingRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ForwardingRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ForwardingRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ForwardingRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ForwardingRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var forwardingRuleResource = new AzureNative.Network.ForwardingRule("forwardingRuleResource", new()
{
    DnsForwardingRulesetName = "string",
    DomainName = "string",
    ResourceGroupName = "string",
    TargetDnsServers = new[]
    {
        
        {
            { "ipAddress", "string" },
            { "port", 0 },
        },
    },
    ForwardingRuleName = "string",
    ForwardingRuleState = "string",
    Metadata = 
    {
        { "string", "string" },
    },
});
Copy
example, err := network.NewForwardingRule(ctx, "forwardingRuleResource", &network.ForwardingRuleArgs{
	DnsForwardingRulesetName: "string",
	DomainName:               "string",
	ResourceGroupName:        "string",
	TargetDnsServers: []map[string]interface{}{
		map[string]interface{}{
			"ipAddress": "string",
			"port":      0,
		},
	},
	ForwardingRuleName:  "string",
	ForwardingRuleState: "string",
	Metadata: map[string]interface{}{
		"string": "string",
	},
})
Copy
var forwardingRuleResource = new ForwardingRule("forwardingRuleResource", ForwardingRuleArgs.builder()
    .dnsForwardingRulesetName("string")
    .domainName("string")
    .resourceGroupName("string")
    .targetDnsServers(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
    .forwardingRuleName("string")
    .forwardingRuleState("string")
    .metadata(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
    .build());
Copy
forwarding_rule_resource = azure_native.network.ForwardingRule("forwardingRuleResource",
    dns_forwarding_ruleset_name=string,
    domain_name=string,
    resource_group_name=string,
    target_dns_servers=[{
        ipAddress: string,
        port: 0,
    }],
    forwarding_rule_name=string,
    forwarding_rule_state=string,
    metadata={
        string: string,
    })
Copy
const forwardingRuleResource = new azure_native.network.ForwardingRule("forwardingRuleResource", {
    dnsForwardingRulesetName: "string",
    domainName: "string",
    resourceGroupName: "string",
    targetDnsServers: [{
        ipAddress: "string",
        port: 0,
    }],
    forwardingRuleName: "string",
    forwardingRuleState: "string",
    metadata: {
        string: "string",
    },
});
Copy
type: azure-native:network:ForwardingRule
properties:
    dnsForwardingRulesetName: string
    domainName: string
    forwardingRuleName: string
    forwardingRuleState: string
    metadata:
        string: string
    resourceGroupName: string
    targetDnsServers:
        - ipAddress: string
          port: 0
Copy

ForwardingRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ForwardingRule resource accepts the following input properties:

DnsForwardingRulesetName
This property is required.
Changes to this property will trigger replacement.
string
The name of the DNS forwarding ruleset.
DomainName This property is required. string
The domain name for the forwarding rule.
ResourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource group. The name is case insensitive.
TargetDnsServers This property is required. List<Pulumi.AzureNative.Network.Inputs.TargetDnsServer>
DNS servers to forward the DNS query to.
ForwardingRuleName Changes to this property will trigger replacement. string
The name of the forwarding rule.
ForwardingRuleState string | Pulumi.AzureNative.Network.ForwardingRuleState
The state of forwarding rule.
Metadata Dictionary<string, string>
Metadata attached to the forwarding rule.
DnsForwardingRulesetName
This property is required.
Changes to this property will trigger replacement.
string
The name of the DNS forwarding ruleset.
DomainName This property is required. string
The domain name for the forwarding rule.
ResourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource group. The name is case insensitive.
TargetDnsServers This property is required. []TargetDnsServerArgs
DNS servers to forward the DNS query to.
ForwardingRuleName Changes to this property will trigger replacement. string
The name of the forwarding rule.
ForwardingRuleState string | ForwardingRuleStateEnum
The state of forwarding rule.
Metadata map[string]string
Metadata attached to the forwarding rule.
dnsForwardingRulesetName
This property is required.
Changes to this property will trigger replacement.
String
The name of the DNS forwarding ruleset.
domainName This property is required. String
The domain name for the forwarding rule.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
String
The name of the resource group. The name is case insensitive.
targetDnsServers This property is required. List<TargetDnsServer>
DNS servers to forward the DNS query to.
forwardingRuleName Changes to this property will trigger replacement. String
The name of the forwarding rule.
forwardingRuleState String | ForwardingRuleState
The state of forwarding rule.
metadata Map<String,String>
Metadata attached to the forwarding rule.
dnsForwardingRulesetName
This property is required.
Changes to this property will trigger replacement.
string
The name of the DNS forwarding ruleset.
domainName This property is required. string
The domain name for the forwarding rule.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource group. The name is case insensitive.
targetDnsServers This property is required. TargetDnsServer[]
DNS servers to forward the DNS query to.
forwardingRuleName Changes to this property will trigger replacement. string
The name of the forwarding rule.
forwardingRuleState string | ForwardingRuleState
The state of forwarding rule.
metadata {[key: string]: string}
Metadata attached to the forwarding rule.
dns_forwarding_ruleset_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the DNS forwarding ruleset.
domain_name This property is required. str
The domain name for the forwarding rule.
resource_group_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the resource group. The name is case insensitive.
target_dns_servers This property is required. Sequence[TargetDnsServerArgs]
DNS servers to forward the DNS query to.
forwarding_rule_name Changes to this property will trigger replacement. str
The name of the forwarding rule.
forwarding_rule_state str | ForwardingRuleState
The state of forwarding rule.
metadata Mapping[str, str]
Metadata attached to the forwarding rule.
dnsForwardingRulesetName
This property is required.
Changes to this property will trigger replacement.
String
The name of the DNS forwarding ruleset.
domainName This property is required. String
The domain name for the forwarding rule.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
String
The name of the resource group. The name is case insensitive.
targetDnsServers This property is required. List<Property Map>
DNS servers to forward the DNS query to.
forwardingRuleName Changes to this property will trigger replacement. String
The name of the forwarding rule.
forwardingRuleState String | "Enabled" | "Disabled"
The state of forwarding rule.
metadata Map<String>
Metadata attached to the forwarding rule.

Outputs

All input properties are implicitly available as output properties. Additionally, the ForwardingRule resource produces the following output properties:

Etag string
ETag of the forwarding rule.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The name of the resource
ProvisioningState string
The current provisioning state of the forwarding rule. This is a read-only property and any attempt to set this value will be ignored.
SystemData Pulumi.AzureNative.Network.Outputs.SystemDataResponse
Metadata pertaining to creation and last modification of the resource.
Type string
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
Etag string
ETag of the forwarding rule.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The name of the resource
ProvisioningState string
The current provisioning state of the forwarding rule. This is a read-only property and any attempt to set this value will be ignored.
SystemData SystemDataResponse
Metadata pertaining to creation and last modification of the resource.
Type string
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
etag String
ETag of the forwarding rule.
id String
The provider-assigned unique ID for this managed resource.
name String
The name of the resource
provisioningState String
The current provisioning state of the forwarding rule. This is a read-only property and any attempt to set this value will be ignored.
systemData SystemDataResponse
Metadata pertaining to creation and last modification of the resource.
type String
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
etag string
ETag of the forwarding rule.
id string
The provider-assigned unique ID for this managed resource.
name string
The name of the resource
provisioningState string
The current provisioning state of the forwarding rule. This is a read-only property and any attempt to set this value will be ignored.
systemData SystemDataResponse
Metadata pertaining to creation and last modification of the resource.
type string
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
etag str
ETag of the forwarding rule.
id str
The provider-assigned unique ID for this managed resource.
name str
The name of the resource
provisioning_state str
The current provisioning state of the forwarding rule. This is a read-only property and any attempt to set this value will be ignored.
system_data SystemDataResponse
Metadata pertaining to creation and last modification of the resource.
type str
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
etag String
ETag of the forwarding rule.
id String
The provider-assigned unique ID for this managed resource.
name String
The name of the resource
provisioningState String
The current provisioning state of the forwarding rule. This is a read-only property and any attempt to set this value will be ignored.
systemData Property Map
Metadata pertaining to creation and last modification of the resource.
type String
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"

Supporting Types

ForwardingRuleState
, ForwardingRuleStateArgs

Enabled
Enabled
Disabled
Disabled
ForwardingRuleStateEnabled
Enabled
ForwardingRuleStateDisabled
Disabled
Enabled
Enabled
Disabled
Disabled
Enabled
Enabled
Disabled
Disabled
ENABLED
Enabled
DISABLED
Disabled
"Enabled"
Enabled
"Disabled"
Disabled

SystemDataResponse
, SystemDataResponseArgs

CreatedAt string
The timestamp of resource creation (UTC).
CreatedBy string
The identity that created the resource.
CreatedByType string
The type of identity that created the resource.
LastModifiedAt string
The type of identity that last modified the resource.
LastModifiedBy string
The identity that last modified the resource.
LastModifiedByType string
The type of identity that last modified the resource.
CreatedAt string
The timestamp of resource creation (UTC).
CreatedBy string
The identity that created the resource.
CreatedByType string
The type of identity that created the resource.
LastModifiedAt string
The type of identity that last modified the resource.
LastModifiedBy string
The identity that last modified the resource.
LastModifiedByType string
The type of identity that last modified the resource.
createdAt String
The timestamp of resource creation (UTC).
createdBy String
The identity that created the resource.
createdByType String
The type of identity that created the resource.
lastModifiedAt String
The type of identity that last modified the resource.
lastModifiedBy String
The identity that last modified the resource.
lastModifiedByType String
The type of identity that last modified the resource.
createdAt string
The timestamp of resource creation (UTC).
createdBy string
The identity that created the resource.
createdByType string
The type of identity that created the resource.
lastModifiedAt string
The type of identity that last modified the resource.
lastModifiedBy string
The identity that last modified the resource.
lastModifiedByType string
The type of identity that last modified the resource.
created_at str
The timestamp of resource creation (UTC).
created_by str
The identity that created the resource.
created_by_type str
The type of identity that created the resource.
last_modified_at str
The type of identity that last modified the resource.
last_modified_by str
The identity that last modified the resource.
last_modified_by_type str
The type of identity that last modified the resource.
createdAt String
The timestamp of resource creation (UTC).
createdBy String
The identity that created the resource.
createdByType String
The type of identity that created the resource.
lastModifiedAt String
The type of identity that last modified the resource.
lastModifiedBy String
The identity that last modified the resource.
lastModifiedByType String
The type of identity that last modified the resource.

TargetDnsServer
, TargetDnsServerArgs

IpAddress This property is required. string
DNS server IP address.
Port int
DNS server port.
IpAddress This property is required. string
DNS server IP address.
Port int
DNS server port.
ipAddress This property is required. String
DNS server IP address.
port Integer
DNS server port.
ipAddress This property is required. string
DNS server IP address.
port number
DNS server port.
ip_address This property is required. str
DNS server IP address.
port int
DNS server port.
ipAddress This property is required. String
DNS server IP address.
port Number
DNS server port.

TargetDnsServerResponse
, TargetDnsServerResponseArgs

IpAddress This property is required. string
DNS server IP address.
Port int
DNS server port.
IpAddress This property is required. string
DNS server IP address.
Port int
DNS server port.
ipAddress This property is required. String
DNS server IP address.
port Integer
DNS server port.
ipAddress This property is required. string
DNS server IP address.
port number
DNS server port.
ip_address This property is required. str
DNS server IP address.
port int
DNS server port.
ipAddress This property is required. String
DNS server IP address.
port Number
DNS server port.

Import

An existing resource can be imported using its type token, name, and identifier, e.g.

$ pulumi import azure-native:network:ForwardingRule sampleForwardingRule /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName} 
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
azure-native-v2 pulumi/pulumi-azure-native
License
Apache-2.0