将新的NIC添加到现有子网
我有一个现有的VNET和子网,并且我正在尝试使用以下二头肌部署新的NIC向子网部署,
param location string = resourceGroup().location
param nicName string
param vNetName string
param subnetName string
resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
name: vNetName
scope: resourceGroup('myRgName')
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing = {
parent: vnet
name: subnetName
}
resource nsg 'Microsoft.Network/networkSecurityGroups@2021-08-01' = {
name: '${nicName}-nsg'
location: location
}
resource nic 'Microsoft.Network/networkInterfaces@2021-08-01' = {
name: nicName
location: location
dependsOn: [
subnet
]
properties: {
ipConfigurations: [
{
name: 'ipConfig'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: subnet
primary: true
privateIPAddressVersion: 'IPv4'
}
}
]
networkSecurityGroup: nsg
}
}
我会编译模板并尝试部署,但我丢失了引用ID的错误值。 PATH属性。IpConfigurations[0] .properties.subnet。
似乎是由手臂未找到子网引起的(存在的,我可以访问)。
json部分看起来像这样
"subnet": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'myRgName'), 'Microsoft.Network/virtualNetworks/subnets', split(parameters('subnetName'), '/')[0], split(parameters('subnetName'), '/')[1]), '2021-02-01', 'full')]",
I have an existing vNet and subnet and I'm trying to deploy a new NIC to the Subnet with the following bicep
param location string = resourceGroup().location
param nicName string
param vNetName string
param subnetName string
resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
name: vNetName
scope: resourceGroup('myRgName')
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing = {
parent: vnet
name: subnetName
}
resource nsg 'Microsoft.Network/networkSecurityGroups@2021-08-01' = {
name: '${nicName}-nsg'
location: location
}
resource nic 'Microsoft.Network/networkInterfaces@2021-08-01' = {
name: nicName
location: location
dependsOn: [
subnet
]
properties: {
ipConfigurations: [
{
name: 'ipConfig'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: subnet
primary: true
privateIPAddressVersion: 'IPv4'
}
}
]
networkSecurityGroup: nsg
}
}
I compile the template and try to deploy but I'm getting the error Value for reference id is missing. Path properties.ipConfigurations[0].properties.subnet.
which appears to be caused by the ARM not finding the subnet (which exists and I have access to).
The json portion of it looks like this
"subnet": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'myRgName'), 'Microsoft.Network/virtualNetworks/subnets', split(parameters('subnetName'), '/')[0], split(parameters('subnetName'), '/')[1]), '2021-02-01', 'full')]",
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用于
NIC属性中的子网参考...如Thomas所述,您需要对
NetworkSecurityGroup
进行相同的操作。Use
for the subnet reference in the NIC's properties... you'll need the same for the
networkSecurityGroup
as Thomas mentioned.