Reputation: 543
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
Reputation: 1
Here are the steps that work for me ...
Upvotes: 0
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
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.
Upvotes: 6
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