Closed BrianVallelunga closed 2 months ago
One for @ninjarobot here!
Fundamentally, VirtualNetwork is not assigned to the SubnetConfig object. I see that in the code, but I'm not sure how it would ever be assigned given the order of creating a vnet first and then adding the subnet to it.
Well, this is a bit odd, but if I add the subnet directly under the vnet, it works. In my testing, the error wasn't even related to the web app, but rather the vnet itself. I would still like to know if there's a way to create the subnets outside of the vnet builder, but at least it works now and this might help someone else.
let primaryVNet =
vnet {
name "myvnet"
add_address_spaces [ "10.1.0.0/16" ]
add_subnets [
subnet {
name "app-services"
prefix "10.1.0.0/24"
add_delegations [ SubnetDelegationService.WebServerFarms ]
}
]
}
let applicationAppService =
webApp {
name applicationAppServiceName
link_to_vnet (primaryVNet, ResourceName "app-services")
depends_on primaryVNet
// ...
}
If the subnet
builder is used standalone, you have to specify the vnet. This is usually used when you want to add a subnet on an existing vmet. If you add that subnet
with add_subnets
on a vnet builder, it will get linked to that parent vnet.
Sorry about that - I know it's a bit confusing, but allows the same builder to work in both cases - standalone and within a vnet. Maybe it needs a better error message.
Thanks @ninjarobot . That makes sense. How do you specify the vnet in that case?
@BrianVallelunga with link_to_vnet
. There is a complete example in this test.
@BrianVallelunga does the link to the test resolve the issue?
@BrianVallelunga can we close this issue?
I'm having issues trying to link an App Service with a VNET. I'm getting the error:
Subnet record must be linked to a virtual network to properly assign the resourceId
Here's the basic structure of my config. Any ideas? I couldn't find an example of how this should be used. Thanks.