你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Bicep 资源定义
可以使用目标操作部署 virtualNetworkGateways/natRules 资源类型:
- 资源组 - 请参阅 资源组部署命令
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
用法示例
Bicep 示例
部署虚拟网络网关 Nat 规则的基本示例。
param resourceName string = 'acctest0001'
param location string = 'westeurope'
resource virtualNetworkGateway 'Microsoft.Network/virtualNetworkGateways@2022-07-01' = {
name: resourceName
location: location
properties: {
activeActive: false
enableBgp: false
enablePrivateIpAddress: false
gatewayType: 'Vpn'
ipConfigurations: [
{
name: 'vnetGatewayConfig'
properties: {
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
id: publicIPAddress.id
}
subnet: {
id: subnet.id
}
}
}
]
sku: {
name: 'Basic'
tier: 'Basic'
}
vpnType: 'RouteBased'
}
}
resource natRule 'Microsoft.Network/virtualNetworkGateways/natRules@2022-07-01' = {
name: resourceName
parent: virtualNetworkGateway
properties: {
externalMappings: [
{
addressSpace: '10.1.0.0/26'
}
]
internalMappings: [
{
addressSpace: '10.3.0.0/26'
}
]
mode: 'EgressSnat'
type: 'Static'
}
}
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-07-01' = {
name: resourceName
location: location
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
dhcpOptions: {
dnsServers: []
}
subnets: []
}
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2022-07-01' = {
name: 'GatewaySubnet'
parent: virtualNetwork
properties: {
addressPrefix: '10.0.1.0/24'
delegations: []
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
serviceEndpointPolicies: []
serviceEndpoints: []
}
}
resource publicIPAddress 'Microsoft.Network/publicIPAddresses@2022-07-01' = {
name: resourceName
location: location
sku: {
name: 'Basic'
tier: 'Regional'
}
properties: {
ddosSettings: {
protectionMode: 'VirtualNetworkInherited'
}
idleTimeoutInMinutes: 4
publicIPAddressVersion: 'IPv4'
publicIPAllocationMethod: 'Dynamic'
}
}
Azure 验证模块
以下 Azure 验证模块 可用于部署此资源类型。
| Module | 描述 |
|---|---|
| 虚拟网络 Gateway - Nat 规则 | 虚拟网络 Gateway 的 AVM 子模块 - Nat 规则 |
资源格式
若要创建 Microsoft.Network/virtualNetworkGateways/natRules 资源,请将以下 Bicep 添加到模板。
resource symbolicname 'Microsoft.Network/virtualNetworkGateways/natRules@2021-05-01' = {
parent: resourceSymbolicName
name: 'string'
properties: {
externalMappings: [
{
addressSpace: 'string'
portRange: 'string'
}
]
internalMappings: [
{
addressSpace: 'string'
portRange: 'string'
}
]
ipConfigurationId: 'string'
mode: 'string'
type: 'string'
}
}
属性值
Microsoft.Network/virtualNetworkGateways/natRules
| 名字 | 描述 | 价值 |
|---|---|---|
| 名字 | 资源名称 | string (必需) |
| 父级 | 在 Bicep 中,可以为子资源指定父资源。 仅当子资源在父资源外部声明时,才需要添加此属性。 有关详细信息,请参阅 父资源外部的子资源。 |
类型资源的符号名称:virtualNetworkGateways |
| 性能 | 虚拟网络网关 NAT 规则的属性。 | VirtualNetworkGatewayNatRuleProperties |
VirtualNetworkGatewayNatRuleProperties
| 名字 | 描述 | 价值 |
|---|---|---|
| externalMappings (外部映射) | NAT 的专用 IP 地址外部映射。 | VpnNatRuleMapping[] |
| internalMappings | NAT 的专用 IP 地址内部映射。 | VpnNatRuleMapping[] |
| ipConfigurationId (ip配置 ID) | 此 NAT 规则适用的 IP 配置 ID。 | 字符串 |
| 模式 | VPN NAT 的源 NAT 方向。 | “EgressSnat” “IngressSnat” |
| 类型 | VPN NAT 的 NAT 规则的类型。 | “Dynamic” “Static” |
VpnNatRuleMapping
| 名字 | 描述 | 价值 |
|---|---|---|
| 地址空间 | Vpn NatRule 映射的地址空间。 | 字符串 |
| 端口范围 | Vpn NatRule 映射的端口范围。 | 字符串 |
ARM 模板资源定义
可以使用目标操作部署 virtualNetworkGateways/natRules 资源类型:
用法示例
资源格式
若要创建 Microsoft.Network/virtualNetworkGateways/natRules 资源,请将以下 JSON 添加到模板。
{
"type": "Microsoft.Network/virtualNetworkGateways/natRules",
"apiVersion": "2021-05-01",
"name": "string",
"properties": {
"externalMappings": [
{
"addressSpace": "string",
"portRange": "string"
}
],
"internalMappings": [
{
"addressSpace": "string",
"portRange": "string"
}
],
"ipConfigurationId": "string",
"mode": "string",
"type": "string"
}
}
属性值
Microsoft.Network/virtualNetworkGateways/natRules
| 名字 | 描述 | 价值 |
|---|---|---|
| apiVersion | API 版本 | '2021-05-01' |
| 名字 | 资源名称 | string (必需) |
| 性能 | 虚拟网络网关 NAT 规则的属性。 | VirtualNetworkGatewayNatRuleProperties |
| 类型 | 资源类型 | “Microsoft.Network/virtualNetworkGateways/natRules” |
VirtualNetworkGatewayNatRuleProperties
| 名字 | 描述 | 价值 |
|---|---|---|
| externalMappings (外部映射) | NAT 的专用 IP 地址外部映射。 | VpnNatRuleMapping[] |
| internalMappings | NAT 的专用 IP 地址内部映射。 | VpnNatRuleMapping[] |
| ipConfigurationId (ip配置 ID) | 此 NAT 规则适用的 IP 配置 ID。 | 字符串 |
| 模式 | VPN NAT 的源 NAT 方向。 | “EgressSnat” “IngressSnat” |
| 类型 | VPN NAT 的 NAT 规则的类型。 | “Dynamic” “Static” |
VpnNatRuleMapping
| 名字 | 描述 | 价值 |
|---|---|---|
| 地址空间 | Vpn NatRule 映射的地址空间。 | 字符串 |
| 端口范围 | Vpn NatRule 映射的端口范围。 | 字符串 |
Terraform (AzAPI 提供程序)资源定义
可以使用目标操作部署 virtualNetworkGateways/natRules 资源类型:
- 资源组 关于每个API版本中变更属性的列表,请参见 更改日志。
用法示例
Terraform 示例
部署虚拟网络网关 Nat 规则的基本示例。
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}
provider "azapi" {
skip_provider_registration = false
}
variable "resource_name" {
type = string
default = "acctest0001"
}
variable "location" {
type = string
default = "westeurope"
}
resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}
resource "azapi_resource" "virtualNetwork" {
type = "Microsoft.Network/virtualNetworks@2022-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
addressSpace = {
addressPrefixes = [
"10.0.0.0/16",
]
}
dhcpOptions = {
dnsServers = [
]
}
subnets = [
]
}
}
schema_validation_enabled = false
response_export_values = ["*"]
lifecycle {
ignore_changes = [body.properties.subnets]
}
}
resource "azapi_resource" "publicIPAddress" {
type = "Microsoft.Network/publicIPAddresses@2022-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
ddosSettings = {
protectionMode = "VirtualNetworkInherited"
}
idleTimeoutInMinutes = 4
publicIPAddressVersion = "IPv4"
publicIPAllocationMethod = "Dynamic"
}
sku = {
name = "Basic"
tier = "Regional"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
resource "azapi_resource" "subnet" {
type = "Microsoft.Network/virtualNetworks/subnets@2022-07-01"
parent_id = azapi_resource.virtualNetwork.id
name = "GatewaySubnet"
body = {
properties = {
addressPrefix = "10.0.1.0/24"
delegations = [
]
privateEndpointNetworkPolicies = "Enabled"
privateLinkServiceNetworkPolicies = "Enabled"
serviceEndpointPolicies = [
]
serviceEndpoints = [
]
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
resource "azapi_resource" "virtualNetworkGateway" {
type = "Microsoft.Network/virtualNetworkGateways@2022-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
activeActive = false
enableBgp = false
enablePrivateIpAddress = false
gatewayType = "Vpn"
ipConfigurations = [
{
name = "vnetGatewayConfig"
properties = {
privateIPAllocationMethod = "Dynamic"
publicIPAddress = {
id = azapi_resource.publicIPAddress.id
}
subnet = {
id = azapi_resource.subnet.id
}
}
},
]
sku = {
name = "Basic"
tier = "Basic"
}
vpnType = "RouteBased"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
timeouts {
create = "180m"
update = "180m"
delete = "60m"
}
}
resource "azapi_resource" "natRule" {
type = "Microsoft.Network/virtualNetworkGateways/natRules@2022-07-01"
parent_id = azapi_resource.virtualNetworkGateway.id
name = var.resource_name
body = {
properties = {
externalMappings = [
{
addressSpace = "10.1.0.0/26"
},
]
internalMappings = [
{
addressSpace = "10.3.0.0/26"
},
]
mode = "EgressSnat"
type = "Static"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
资源格式
若要创建 Microsoft.Network/virtualNetworkGateways/natRules 资源,请将以下 Terraform 添加到模板。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.Network/virtualNetworkGateways/natRules@2021-05-01"
name = "string"
parent_id = "string"
body = {
properties = {
externalMappings = [
{
addressSpace = "string"
portRange = "string"
}
]
internalMappings = [
{
addressSpace = "string"
portRange = "string"
}
]
ipConfigurationId = "string"
mode = "string"
type = "string"
}
}
}
属性值
Microsoft.Network/virtualNetworkGateways/natRules
| 名字 | 描述 | 价值 |
|---|---|---|
| 名字 | 资源名称 | string (必需) |
| parent_id | 此资源的父资源的 ID。 | 类型资源的 ID:virtualNetworkGateways |
| 性能 | 虚拟网络网关 NAT 规则的属性。 | VirtualNetworkGatewayNatRuleProperties |
| 类型 | 资源类型 | “Microsoft.Network/virtualNetworkGateways/natRules@2021-05-01” |
VirtualNetworkGatewayNatRuleProperties
| 名字 | 描述 | 价值 |
|---|---|---|
| externalMappings (外部映射) | NAT 的专用 IP 地址外部映射。 | VpnNatRuleMapping[] |
| internalMappings | NAT 的专用 IP 地址内部映射。 | VpnNatRuleMapping[] |
| ipConfigurationId (ip配置 ID) | 此 NAT 规则适用的 IP 配置 ID。 | 字符串 |
| 模式 | VPN NAT 的源 NAT 方向。 | “EgressSnat” “IngressSnat” |
| 类型 | VPN NAT 的 NAT 规则的类型。 | “Dynamic” “Static” |
VpnNatRuleMapping
| 名字 | 描述 | 价值 |
|---|---|---|
| 地址空间 | Vpn NatRule 映射的地址空间。 | 字符串 |
| 端口范围 | Vpn NatRule 映射的端口范围。 | 字符串 |