Search code examples
asp.netazuredeploymentazure-virtual-networkvirtual-network

How can I deploy an ASP.NET MVC 5 Web App to a Virtual Network in Azure


I have an existing ASP.Net MVC 5 Web Application (and associated web services) that I've been asked to deploy into a specific VNet (virtual network) within Azure. I've googled this to death and struck out.

The best I've found is to edit a ServiceConfiguration.cscfg file to include a node like this:

<NetworkConfiguration>
  <VirtualNetworkSite name="Test-VNet" />
  <AddressAssignments>
    <InstanceAddress roleName="Test-Role-1">
      <Subnets>
        <Subnet name="Subnet-1" />
      </Subnets>
    </InstanceAddress>
  </AddressAssignments>
</NetworkConfiguration>

The problem with this is that .cscfg files APPEAR to be unique to Azure Cloud Service Deployment projects, which don't appear to be of any help when deploying an Azure Web Site. If this is the only way then I'm going to have to create a bunch of Cloud Service projects, port the code into them and then re-test. This is likely to be pretty time-consuming and I don't think that management will appreciate the risk.

Am I going to have to re-create the Web Application projects into Azure Cloud Services to deploy them into VNets, or is there another way...?


Solution

  • In the end I gave in, created Cloud Service projects (with associated deployment packages) to replace the web services and ported the code across. It didn't take too long and required very few code tweaks. The public facing web site I left as a standard Web Application.

    Having done this I was able to deploy my private Web Services (now cloud services) into Azure Virtual Networks, where they were hidden from the outside world, and configure the public web site to allow it to access the components within the VNet.