Simon Needham
Simon Needham

Reputation: 543

Deploy an ASP.net MVC website to a subfolder of an Azure website?

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.

Upvotes: 7

Views: 8324

Answers (4)

Gyanesh sharma
Gyanesh sharma

Reputation: 1

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.

Upvotes: 0

Azure-Techno
Azure-Techno

Reputation: 106

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
        }

Upvotes: 0

Bigs
Bigs

Reputation: 616

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

Upvotes: 6

LionSoft
LionSoft

Reputation: 1509

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.

Upvotes: 7

Related Questions