Search code examples
asp.net-mvciisazure-devopsazure-virtual-machineazure-deployment

Deploy two different ASP.NET applications to the same Azure VM with IIS


WEBSITE 1: I had a single ASP.NET MVC site in Visual Studio online and was building and then releasing from the Visual Studio Online to that Virtual machine.

enter image description here

WEBSITE 2: I decided to create another Solution/Project in Visual Studio online and run it off the same Virtual Machine (with continuous integration, etc). As part of setting up Deployment Groups for that project, I wanted to add the same virtual machine as for project 1 (I believe I cannot share Deployment Groups between projects).

When I executed the VSTS Agent script for site 2 on the virtual machine, the first website's target went "offline", and the machine lit up in the SITE 2 Deployment Group, disappearing from SITE 1 Deployment Group.

There seems to be only one VSTS Agent that can be set up to receive website deployments:

enter image description here

Question: How can I set up the same virtual machine with IIS to receive deployments for two separate websites within the same VS Online account? Is there a way to set up multiple VSTS Agents on a Azure Virtual machine?


Solution

  • It is possible to deploy multiple agents for VSTS in a machine. You can use steps below to achieve this in azure VM or any single machine, when setting up deployment groups.

    1. Copy the target registration PowerShell script to a notepad. Then replace the

      $env:SystemDrive\'vstsagent'

    with a local path of your preference for agent for example

    'g:\vstsagentprojX'
    

    This will make the agent installed for project X deployment group setup in g:\vstsagentprojX.

    enter image description here

    1. Replace

      --agent $env:COMPUTERNAME

    in the script with project specific name for example

    --agent chamindac.projx
    

    enter image description here

    1. Then register the agent for Project X deployment group and it will be configured in the specified folder,

    enter image description here

    and with a unique service name since you have provided a project specific name for agent.

    enter image description here

    Follow steps similar to the other project and change its PowerShell script to have the

    $env:SystemDrive\'vstsagent'
    

    replace with project specific path for local folder say

    'g:\vstsagentprojQ'
    

    Then change --agent $env:COMPUTERNAME to a project specific name such as

    --agent chamindac.projq
    

    Then run the script to create the deployment group agent for the second project.

    enter image description here

    This will create two agent services with unique names in the same machine. enter image description here

    You should have two targets in two team project deployment groups, online.

    enter image description here