我正在使用ARM模板创建:
根据所有教程,我正在尝试为网关创建子网,然后通过id将此网关连接到子网。 不幸的是我收到了很奇怪的错误回复:
{
"error": {
"code": "InvalidTemplateDeployment",
"message": "The template deployment 'shared' is not valid according to the validation procedure. The tracking id is '01a1ff01-14ec-4dd3-93f7-5392aca02532'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details.",
"details": [
{
"code": "GatewaySubnet",
"message": "Subnet with name 'GatewaySubnet' can be used only for the Gateway resource.",
"details": []
}
]
}
}
我想创建此子网以供网关使用。稍后在模板中,此网关引用此子网。我找不到任何可疑的东西..
这是模板(整个模板要大得多,但我希望只提取与网络相关的信息)。如果您还有其他需要,请告诉我。我没有说明一切,但我希望这已经足够了。
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('networkSettings').virtualNetworkName]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('networkSettings').addressPrefix]"
]
},
"subnets": [
{
"name": "[parameters('networkSettings').subnet.master.name]",
"properties": {
"addressPrefix": "[parameters('networkSettings').subnet.master.prefix]"
}
},
{
"name":"GatewaySubnet",
"properties":{
"addressPrefix":"[parameters('networkSettings').subnet.gateway.prefix]"
}
}
]
}
},
{
"apiVersion":"2016-03-30",
"type":"Microsoft.Network/publicIPAddresses",
"name":"[parameters('networkSettings').subnet.gateway.publicIp]",
"location":"[resourceGroup().location]",
"properties":{
"publicIPAllocationMethod":"Dynamic"
}
},
{
"apiVersion": "2016-03-30",
"type":"Microsoft.Network/networkInterfaces",
"name":"[parameters('networkSettings').subnet.gateway.name]",
"location":"[resourceGroup().location]",
"dependsOn":[
"[concat('Microsoft.Network/publicIPAddresses/', parameters('networkSettings').subnet.gateway.publicIp)]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('networkSettings').virtualNetworkName)]"
],
"properties":{
"ipConfigurations":[
{
"properties":{
"privateIPAllocationMethod":"Dynamic",
"subnet":{
"id":"[variables('gatewaySubnetRef')]"
},
"publicIPAddress":{
"id":"[resourceId('Microsoft.Network/publicIPAddresses',parameters('networkSettings').subnet.gateway.publicIp)]"
}
},
"name":"vnetGatewayConfig"
}
],
"sku": {
"name": "[parameters('networkSettings').subnet.gateway.sku]",
"tier": "[parameters('networkSettings').subnet.gateway.sku]"
},
"gatewayType":"Vpn",
"vpnType":"RouteBased",
"enableBgp":"false",
"vpnClientConfiguration":{
"vpnClientAddressPool":{
"addressPrefixes":[
"[parameters('networkSettings').subnet.gateway.vpnClientAddressPoolPrefix]"
]
},
"vpnClientRootCertificates":[
{
"name": "[parameters('networkSettings').subnet.gateway.clientRootCertName]",
"properties":{
"PublicCertData":
"[parameters('networkSettings').subnet.gateway.clientRootCertData]"
}
}
]
}
}
}
答案 0 :(得分:0)
在模板中间,您有一个网络接口,PIP被分配给gatewaySubnet
"properties":{
"privateIPAllocationMethod":"Dynamic",
"subnet":{
"id":"[variables('gatewaySubnetRef')]"
},
"publicIPAddress":{
"id":"[resourceId('Microsoft.Network/publicIPAddresses',parameters('networkSettings').subnet.gateway.publicIp)]"
}
部署失败,因为它只期望在该子网中拥有VPN网关。我认为你的意思是把"[parameters('networkSettings').subnet.master.prefix]"
放在那里。
默认情况下,无需为其拥有的网关创建公共IP。