简体   繁体   中英

Azure Bastion into Existing Vnet

Hi I'm trying to deploy an AzureBastion into a seperate vnet which is in a separate resourcegroup from the bastion. I keep getting the error below,

New-AzSubscriptionDeployment : 10:49:03 - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The resource 
'Microsoft.Network/virtualNetworks/vnet1/subnets/AzureBastionSubnet' is not defined in the template. Please see https://aka.ms/arm-template for usage details.'.
At C:\Temp\New-Deployment\deploy-core.ps1:53 char:1

The template is at

"https://pastebin.com/embed_js/ET9HwFJ9"

Can anyone see where I'm going wrong, driving me insane

I should add this is a nested template, called by a master template. which is below:

"https://pastebin.com/embed_js/Uf3asC9c"

Thanks in advance :)

Please follow the following ARM template, it allows you to:

**- Add the subnet “AzureBastionSubnet” which is required to create a Bastion.

  • Create the Public Address Ip for the Bastion.
  • Create the Bastion.**

Deploy template.json:

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "location": {
        "type": "string"
    },
    "resourceGroup": {
        "type": "string"
    },
    "bastionHostName": {
        "type": "string"
    },
    "subnetName": {
        "type": "string"
    },
    "publicIpAddressName": {
        "type": "string"
    },
    "existingVNETName": {
        "type": "string"
    },
    "subnetAddressPrefix": {
        "type": "string"
    }
},
"resources": [
    {
        "apiVersion": "2019-02-01",
        "type": "Microsoft.Network/publicIpAddresses",
        "name": "[parameters('publicIpAddressName')]",
        "location": "[parameters('location')]",
        "sku": {
            "name": "Standard"
        },
        "properties": {
            "publicIPAllocationMethod": "Static"
        },
        "tags": {}
    },
    {
        "apiVersion": "2018-04-01",
        "type": "Microsoft.Network/virtualNetworks/subnets",
        "name": "[concat(parameters('existingVNETName'), '/', parameters('subnetName'))]",
        "location": "[parameters('location')]",
        "properties": {
          "addressPrefix": "[parameters('subnetAddressPrefix')]"
        }
      },
    {
        "apiVersion": "2018-10-01",
        "type": "Microsoft.Network/bastionHosts",
        "name": "[parameters('bastionHostName')]",
        "location": "[parameters('location')]",
        "dependsOn": [
            "[resourceId(parameters('resourceGroup'), 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
        ],
        "properties": {
            "ipConfigurations": [
                {
                    "name": "IpConf",
                    "properties": {
                        "subnet": {
                            "id": "[resourceId(parameters('resourceGroup'), 'Microsoft.Network/virtualNetworks/subnets', parameters('existingVNETName'),parameters('subnetName'))]"
                        },
                        "publicIPAddress": {
                            "id": "[resourceId(parameters('resourceGroup'), 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
                        }
                    }
                }
            ]
        },
        "tags": {}
    }
]

}

Paramtere template:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "resourceGroup": {
        "value": "testAmine"
    },
    "bastionHostName": {
        "value": "TestBast"
    },
    "publicIpAddressName": {
        "value": "testamine-vnet-ip"
    },
    "subnetName": {
        "value": "AzureBastionSubnet"
    },
    "existingVNETName":
    {
        "value": "testamine-vnet"
    },
    "subnetAddressPrefix":
    {
        "value": "10.0.1.0/27"
    },
    "location": {
        "value": "westeurope"
    }
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM