连接用于天蓝色堡垒部署的子网ID参考

时间:2020-09-16 22:27:38

标签: json azure arm-template

有人可以看到这有什么问题吗?我正在尝试引用另一个资源组中的资源。我正在部署堡垒主机,并想引用另一个资源组(vnet rg)中的子网

这是我所拥有的,但不起作用,我需要参考订阅吗?格式不正确,但尝试了我可以做的所有事情:(

        "id": "[concat('/','subscriptions','/','parameters('SubscriptionId'),'/','resourceGroups','/',parameters('vnetResourceGroupName'),'/',providers','/','Microsoft.Network','/','virtualNetworks','/','parameters('vnetName'),'/','subnets','/','AzureBastionSubnet'))]"

我正在尝试这个(ish)

"id":"/subscriptions/xxxxx-xxxxx-xxxx-xxxxx-xxxxxxxxxx/resourceGroups/rg-vnet/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/SubnetName"

当我尝试使用resourceID时

        "id": "[resourceId(parameters('vnetResourceGroupName'), 'Microsoft.Network/virtualNetworks/', parameters('vnetName'), '/subnets/AzureBastionSubnet')]"

我收到此错误:

'resourceId': function requires exactly one multi-segmented argument which must be resource type including resource provider namespace. Current function arguments 
'rg-vnet,Microsoft.Network/virtualNetworks/,vnet1,/subnets/AzureBastionSubnet'

我认为这是导致问题的每个段之间的逗号:( 在此先感谢:)

1 个答案:

答案 0 :(得分:0)

正确格式:

“ id”:“ [resourceId(parameters('vnetResourceGroupName'),'Microsoft.Network/virtualNetworks/subnets',parameters('VNETName'),variables('subnetName'))]“