locked
Run 2 MVC Apps in one Azure's Web App RRS feed

  • Question

  • User-1134857695 posted

    Sup! There's little information regarding this topic. I'd like to publish two apps (My main and MVCForum) to the same Azure Web Application. I read that virtual directories could prove helpful, but I haven't got them right yet. I made a virtual directory called /forum and published MVCForum to it. 

    But it seems that my main MVC app is conflicting with MVCForum, I can tell because I can't run them simultaneously on my local environment. 

    I applied to the topmost part of the RouteConfig.cs of my main MVC app the following code:

    routes.IgnoreRoute("forum/{*pathInfo}");

    But that hasn't done anything to the app. 

    I think that the problem could be around namespaces... But don't know how to do it.  Any suggestions? Thanks.

    Friday, December 4, 2015 3:12 AM

Answers

  • User1070236303 posted

    It seems that the old management portal is gone, and the preview portal is now live. (This is a bad news. because now we need to work with a bloated, over complicated and crap portal.) Good luck to find any documentation for the new management portal (you won't find any)

    What you want is possible. I have experience only with total independent apps (different virtual directories and bindings in iis)

    1. You need to create a new Cloude services (Classic) in azure. This called in the past "Web role"

    2. Create two total independent web application. That means on your dev machine both application has independent virtual directory and in the binding different port number.

    3. Create a solution, add web applications.

    4. Add Azure Cloud Service to the solution (it is ok to link it to one of your web application)

    5. You can add any number of application in the ServiceDefinition.csdef

    You have two option using host headers, or different port numbers. You can try out other combinations (custom dns names etc.)

    Examples:

    Host header version:

    <Sites>
    
          <Site name="Web1" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="web1.[cloud service name].cloudapp.net"/>
            </Bindings>
          </Site>
          <Site name="Web2" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="web2.[cloud service name].cloudapp.net" />
            </Bindings>
          </Site>
    
    </Sites>
        <Endpoints>
              <InputEndpoint name="Endpoint1" protocol="http" port="80" />
        </Endpoints>

    Using different ports:

    <Sites>
    
          <Site name="Web1" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" />
            </Bindings>
          </Site>
          <Site name="Web2" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint2" endpointName="Endpoint2"  />
            </Bindings>
          </Site>
    
    </Sites>
        <Endpoints>
              <InputEndpoint name="Endpoint1" protocol="http" port="80" />
              <InputEndpoint name="Endpoint2" protocol="http" port="8080" />
        </Endpoints>

    6. Package your cloud service and upload it to azure.

    Now you can browse your apps as:

    http://web1.[cloud service name].cloudapp.net/

    http://web2.[cloud service name].cloudapp.net/

    or

    http://[cloud service name].cloudapp.net/

    http://[cloud service name].cloudapp.net:8080/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 4, 2015 7:53 AM

All replies

  • User1070236303 posted

    It seems that the old management portal is gone, and the preview portal is now live. (This is a bad news. because now we need to work with a bloated, over complicated and crap portal.) Good luck to find any documentation for the new management portal (you won't find any)

    What you want is possible. I have experience only with total independent apps (different virtual directories and bindings in iis)

    1. You need to create a new Cloude services (Classic) in azure. This called in the past "Web role"

    2. Create two total independent web application. That means on your dev machine both application has independent virtual directory and in the binding different port number.

    3. Create a solution, add web applications.

    4. Add Azure Cloud Service to the solution (it is ok to link it to one of your web application)

    5. You can add any number of application in the ServiceDefinition.csdef

    You have two option using host headers, or different port numbers. You can try out other combinations (custom dns names etc.)

    Examples:

    Host header version:

    <Sites>
    
          <Site name="Web1" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="web1.[cloud service name].cloudapp.net"/>
            </Bindings>
          </Site>
          <Site name="Web2" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="web2.[cloud service name].cloudapp.net" />
            </Bindings>
          </Site>
    
    </Sites>
        <Endpoints>
              <InputEndpoint name="Endpoint1" protocol="http" port="80" />
        </Endpoints>

    Using different ports:

    <Sites>
    
          <Site name="Web1" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint1" endpointName="Endpoint1" />
            </Bindings>
          </Site>
          <Site name="Web2" physicalDirectory="[Path to your app on the dev machine]">
            <Bindings>
              <Binding name="Endpoint2" endpointName="Endpoint2"  />
            </Bindings>
          </Site>
    
    </Sites>
        <Endpoints>
              <InputEndpoint name="Endpoint1" protocol="http" port="80" />
              <InputEndpoint name="Endpoint2" protocol="http" port="8080" />
        </Endpoints>

    6. Package your cloud service and upload it to azure.

    Now you can browse your apps as:

    http://web1.[cloud service name].cloudapp.net/

    http://web2.[cloud service name].cloudapp.net/

    or

    http://[cloud service name].cloudapp.net/

    http://[cloud service name].cloudapp.net:8080/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 4, 2015 7:53 AM
  • User-1134857695 posted

    One million thank you. I'll be working on it right now. Will post back after accomplishing the task.

    Edit: Dec 12th, 2015: Even though I started using Azure with the new portal (I'm only 1 month old working with Azure), I have seen that the old portal works for several things, like for example getting the Web App IP Address and creating the cloud service, which I couldn't do in the new portal... 

    Saturday, December 5, 2015 2:09 PM
  • User-1134857695 posted

    stmarti: 

    Thanks a lot... REALLY! You've helped me through all of this. I ended up using two separate Web Apps. There were two main reasons I did not perceive at a previous time. The first one was Cloud Services do not allow me to upload the changing files to the server. The only workaround that we have is temporary. I have an unstable Internet connection which I wouldn't rely on if I need to do some quick fix. 

    I do really like Cloud Apps because they are cheaper to use and I can have a staging process for quickly testing my settings.  Unfortunately the package-only upload is a deal breaker for me :/ 

    The second thing that I didn't take into consideration was the MVC framework itself. This MVC app, although nothing special, will try to expand to many platforms as possible, and MVC 6 is the road to go. 

    On a single Web App solution, I can't have running 2 different MVC frameworks at the same time (I'm planning on upgrading on MVC 6 as soon as it hits Release To Web - RTW)

    If you think that what I"m doing could be improved, and I could benefit even more from Cloud Services I will reconsider them and can do the migration work. 

    Tuesday, December 8, 2015 1:41 AM
  • User-1134857695 posted

    Ok. I've been thinking a little bit. Cloud Services does offer a much better option. SSL is included in the basic price and it will be much cheaper to run it. What I'll do is to try how it will go with Web Apps a month, and see how well it goes through. 

    Tuesday, December 8, 2015 2:17 AM
  • User1070236303 posted

    Web app (called previously web sites) are good for small sites.

    You can scale up web app for dedicated instances, but that will be equivalent to a cloud service. For web app you need to pay a ridiculous high price for ssl support.

    (I really don't know what is the diff between the dedicated instance web app and the cloud service)

    In cloud service you can configure ssl free (as you find out). Also you have full control: you can install asp.net 4.6 (not included in any current VM!), change IIS settings etc.

    The followings are very personal opinion about vnext (but I'm not alone)

    It is very-very far from a final product. The biggest problems with vnext (for me):

    - big productivity loss (built in visual studio tooling is gone, you need to use command prompt, npm, gulp, grunt whatever. It is a complete mess. Example: You can bundle/minify/version css, javascript with two lines of c#code in asp.net, the same in vnext is a disaster.)

    - net.core is a joke

    - a complete rewrite needed for real apps(!)

    - no documentation, no migration guide, nothing. But you will find tons of blog post about hello word tutorials...

    So I will wait at least one year, and lets see what happens :)

    Wednesday, December 9, 2015 10:54 AM