Custom deployment folder on Azure Web Apps with Git

Sometimes you don't want to deploy your application in the default webapps directory when deploying from GitHub (continuous deployment) on Azure webapp. You can do this in 2 ways -

1. Use the SCM_TARGET_PATH to set your path which can be absolute or relative to the D:\home\site path.

   

 

2. Create two files in your git root:

.deployment

 [config] command=deploy.cmd 

deploy.cmd

 @echo off 
 echo ---Deploying site 
  
 REM ---Deploy the wwwroot folder in repository to default target (wwwroot)
 xcopy %DEPLOYMENT_SOURCE%\wwwroot\* %DEPLOYMENT_TARGET%/Y /s 
  
 REM ---Deploy the myapp folder in repository to folder above default target (wwwroot\..\myapp)
 xcopy %DEPLOYMENT_SOURCE%\myapp\* %DEPLOYMENT_TARGET%\..\myapp /Y /s 
  

 Commit, push

 

Remember if you are customizing the deployment folder also set the application folder in the Azure portal accordingly, so that Azure recognizes the custom application folder -

 

In case you have a Java webapp and want to change the default context you can refer to my blog - https://blogs.msdn.com/b/azureossds/archive/2015/12/11/use-custom-context-for-azure-tomcat-application.aspx.

Good Luck!!