【发布时间】:2022-02-18 19:58:44
【问题描述】:
我花了几天时间试图找出如何使用二头肌将路由表链接到子网。我在网上找到的与此相关的文档数量为零。显然,它以前已经完成了 - 但我做错了什么?
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
name: 'coolname'
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [
'10.156.0.0/15'
]
}
subnets: [
{
name: 'CloudGuardExternal'
properties: {
addressPrefix: '10.156.0.0/24'
routeTable: // <---------- LOOK HERE
}
}
]
}
}
resource routeTableNumberOne 'Microsoft.Network/routeTables@2020-11-01' = {
name: 'routelol'
location: 'australiaeast'
properties: {
disableBgpRoutePropagation: false
routes: [
{
name: 'dropPacketTestRoute'
properties: {
addressPrefix: '10.0.0.0/8'
nextHopType: 'None'
hasBgpOverride: false
}
}
]
}
}
我创建了一个资源组。在其中,创建了一个子网。我还创建了一个包含示例路由的路由表。
我花了几天时间试图找出如何填写 routeTable 属性。我没有收到错误 - 没有任何反应。没有错误,当我部署代码时,门户上没有任何内容。
更新
subnets: [
{
name: 'CloudGuardExternal'
properties: {
addressPrefix: '10.156.0.0/24'
routeTable: routeTableNumberOne
}
}
]
我通过 CLI 命令而不是管道尝试了上述操作,这次我收到一条错误消息说明
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At 至少一项资源部署操作失败。请列出部署 详细操作。请参阅https://aka.ms/DeployOperations 使用详情。","details":[{"code":"BadRequest","message":"{\r\n "错误": {\r\n "代码": "InvalidRequestFormat",\r\n
"message": "无法解析请求。",\r\n "details": [\r\n {\r\n "代码": "MissingJsonReferenceId",\r\n
"message": "缺少参考 id 的值。路径 properties.subnets[0].properties.routeTable。"\r\n }\r\n ]\r\n }\r\n}"}]}}
这对我来说真的是个好消息,因为至少我现在有一个错误!
更新 #2
subnets: [
{
name: 'CloudGuardExternal'
properties: {
addressPrefix: '10.156.0.0/24'
routeTable: routeTableNumberOne.properties.routes[0]
}
}
]
我尝试了上述方法,但这次得到了不同的错误消息:
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At 至少一项资源部署操作失败。请列出部署 详细操作。请参阅https://aka.ms/DeployOperations 使用详情。","details":[{"code":"BadRequest","message":"{\r\n "错误": {\r\n "代码": "InvalidRequestFormat",\r\n
"message": "无法解析请求。",\r\n "details": [\r\n {\r\n "代码": "InvalidJsonReferenceWrongType",\r\n
“消息”:“参考 ID /subscriptions/ee8bbd18-7563-42cd-b616-53841d3f3b28/resourceGroups/hub/providers/Microsoft.Network/routeTables/routelol/routes/dropPacketTestRoute 正在引用错误类型的资源。该 ID 预计将 routeTables 类型的参考资源。小路 properties.subnets[0].properties.routeTable。"\r\n }\r\n ]\r\n }\r\n}"}]}}
更新 #3
我尝试了以下
subnets: [
{
name: 'CloudGuardExternal'
properties: {
addressPrefix: '10.156.0.0/24'
routeTable: {
properties: {
routes: [
{
properties: {
addressPrefix: '10.0.0.0/8'
nextHopType: 'None'
}
}
]
}
}
}
}
]
但这一次,得到以下错误信息
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At 至少一项资源部署操作失败。请列出部署 详细操作。请参阅https://aka.ms/DeployOperations 使用详情。","details":[{"code":"BadRequest","message":"{\r\n "错误": {\r\n "代码": "InvalidRequestFormat",\r\n
"message": "无法解析请求。",\r\n "details": [\r\n {\r\n "代码": "MissingJsonReferenceId",\r\n
"message": "缺少参考 id 的值。路径 properties.subnets[0].properties.routeTable。"\r\n }\r\n ]\r\n }\r\n}"}]}}
更新 4
subnets: [
{
name: 'CloudGuardExternal'
properties: {
addressPrefix: '10.156.0.0/24'
routeTable: {
id: 'nameonecool'
properties: {
routes: [
{
properties: {
addressPrefix: '10.0.0.0/8'
nextHopType: 'None'
}
}
]
}
}
}
}
]
现在,我收到此错误:
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At 至少一项资源部署操作失败。请列出部署 详细操作。请参阅https://aka.ms/DeployOperations 使用详情。","details":[{"code":"BadRequest","message":"{\r\n "错误": {\r\n "代码": "LinkedInvalidPropertyId",\r\n
“消息”:“路径中的属性 id 'nameonecool' 'properties.subnets[0].properties.routeTable.id' 无效。预计 以 '/subscriptions/{subscriptionId}' 或 '/providers/{resourceProviderNamespace}/'。"\r\n }\r\n}"}]}}
好的,至少这个错误看起来很独特!
【问题讨论】:
标签: amazon-web-services azure azure-resource-manager infrastructure-as-code