When creating a NatGateway, how to associate it with a Subnet of an existing Vnet #12817
Unanswered
coffeejunjun
asked this question in
Q&A
Replies: 3 comments
-
Trying the same |
Beta Was this translation helpful? Give feedback.
0 replies
-
Also trying to do this as well. Subnet and nat gateway are in the same deployment but for some reason it doesn't associate. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, when creating a NAT Gateway with bicep, you can associate it with an existing subnet. var existingVNetName = 'vnet-1'
var existingSubnetName = 'subnet-1'
resource vnet 'Microsoft.Network/virtualNetworks@2023-05-01' existing = {
name: existingVNetName
}
resource natgateway 'Microsoft.Network/natGateways@2023-06-01' = {
// trimmed params
}
resource updatedsubnet01 'Microsoft.Network/virtualNetworks/subnets@2023-06-01' = {
parent: vnet
name: existingSubnetName // this needs to be static values, as calculated at start of deployment. so you cannot put the name of subnet as vnet.properties.subnets[0].properties.name
properties: {
addressPrefix: vnet.properties.subnets[0].properties.addressPrefix
natGateway: {
id: natgateway.id
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello.
When creating a NatGateway in Bicep, is there a way to tie it to a Subnet of a Vnet that has already been created?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions