7

I have an asp.net mvc website that I'd like to deploy to Azure (preferably via GitHub deployment) so that it's accessed as subfolder of the main domain.

e.g. http://example.com/mymvcsite/

Ideally I'd like the website to be completely self-contained under the subfolder. As if it was configured to be a good old-fashioned IIS application folder. Ie I don't wanty to build a domain mvc website for mydomain.com that just happens to do all it's business under the /mymvcsite/ subfolder path.

I'm quite happy for the entire website to be hosted on Azure, it just makes sense for this particular project to live under a subfolder.

I've been struggling and googling today, trying to figure out how to go about this and have come up blank.

5
  • Why not deploy it to the root and add the subfolder path using routing?
    – amhed
    Commented Feb 21, 2013 at 10:47
  • @ahmed Well ideally I may want to add additional application sub-folders in future. It would get me going for now though. Are suggesting I can ad routes in my Azure service files? Commented Feb 21, 2013 at 14:49
  • You can just add additional routes in your RouteConfig.cs (or even better areas)
    – amhed
    Commented Feb 21, 2013 at 14:59
  • @ahmed I'm going with Areas. It appears to be as close to what I'd like as I'm going to get without just spinning up a VM in Azure and setting up an Application Folders in IIS. Commented Feb 22, 2013 at 9:02
  • 1
    I've changed the accepted answer to @Bigs. Since I asked the question in Feb-2013 MS have provided and easy way to do this in the Azure control panel.For what it's worth I did go with ahmed's suggestion at the time. Commented Nov 7, 2014 at 10:20

4 Answers 4

7

If you use Web deploy publish method you can set in Site name mydomain/mymvcsite instead of mydomain. At least it works for me for default windows azure site http://mydomain.azurewebsites.net/mymvcsite.

Or you can use FTP publish method.

2
  • 1
    I tried this, with Web Deploy on 1st deployment it created /site/wwwroot/stats/ (what I wanted) but on second try I ended up with /site/wwwroot/wwwroot/stats/.
    – htuomola
    Commented May 14, 2014 at 9:35
  • 1
    To avoid that recursion,please ensure the profile's "SiteName" and "DestinationURL" point to the same subfolder. Commented Feb 25, 2019 at 7:33
6

You can just go to azure's control panel and add in a virtual directory path.

Please visit this MDSN blog to see how its done.

http://blogs.msdn.com/b/kaushal/archive/2014/04/19/microsoft-azure-web-sites-deploying-wordpress-to-a-virtual-directory-within-the-azure-web-site.aspx

0

Basically this needs following steps to be done to make it working.

Solution contains

i) sampleApp.API(.Net Core Web API)

ii)sampleApp.UI( Angular App)

Setting up Azure portal for two applications

1) Go to your web app in azure portal -> Settings->configurations

2) Select Path Mappings and here create new mapping entry for subsite .While adding this entry don't select directory checkbox to keep this as virtual application type.Click save

 **Virtual Path:** /{folderName}            **physicalPath:**  /site/wwwroot/{folderName} 

3) Now go to VS2017 right click your API project and click publish

4) In publish settings window make paths as

site name : existing + "/{folderName} "
DestinationUrl : existing + "/{folderName} "

5) Now ng-build --prod your angular app and deploy dist/clientApp folder and publish with root paths.

so now both should work as

angular app https://{AzureAppName}.azurewebsites.net

Web API https://{AzureAppName}.azurewebsites.net/{folderName}/api/{controllerName}/{action}

If still user face "cant read configuration data from web.config" issue while accessing api project

For this in your API project go to startup.cs and change configure function to have following line of code

app.Map('/{folderName}', app1 => Configure1(app1, loggerFactory);

and create in blank copy of configure function with name configure1 and redeploy your API project as mentioned above.

public void Configure1(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            //keep it blank
        }
0

Here are the steps that work for me ...

  1. Publish your code to your local using visual studio publish option.
  2. Login to related azure virtual machine maybe using RDP.
  3. Copy paste published code from your local to the subfolder inside virtual machine.
  4. Open IIS and create new site there, provide site-name and port values (eg. 81).
  5. Go to windows defender firewall and create an inbound rule targeting above port number to access the newly created site outside to virtual machine.

Not the answer you're looking for? Browse other questions tagged or ask your own question.