14
votes

This would seem to be an easy task although I can't find the solution. I've recently started a Laravel 4 project which needs to be hosted on Azure. I've linked Azure to deploy from bitbucket when a change is made. This however pushes the files into "wwwroot" folder in Azure (the public folder). Some of the framework files shouldn't be in the public folder therefore I would like to push to the parent folder "site".

After some research I discovered you can use .deployment file to config deployment options (https://github.com/projectkudu/kudu/wiki/Deployment-hooks)

So I tried .deployment file:

[config]
DEPLOYMENT_TARGET = C:\DWASFiles\Sites\SITENAME\VirtualDirectory0\site

Unfortunately this causes an error:

Source and destination directories cannot be sub-directories of each other

This would be due to the fact the repository folder sits in the site folder aswell. If I change the deployment file to:

[config]
DEPLOYMENT_SOURCE = C:\DWASFiles\Sites\SITENAME\VirtualDirectory0\repo
DEPLOYMENT_TARGET = C:\DWASFiles\Sites\SITENAME\VirtualDirectory0\site

It runs without errors but it pushes nothing as the repo folder is empty, I guess if I could get Azure to put the files into \repo instead \site\repository everything would be fine.

Maybe I'm over complicating things and I'd really appreciate any advice. Worst case I can just push to the "wwwroot" folder and use a web.config to fix things.

4
Do you need those files in the parent folder to be there at all at runtime?David Ebbo

4 Answers

7
votes

This is not very well supported today, but you may be able to make it work by setting a couple things in the app settings:

SCM_REPOSITORY_PATH=..\repository
SCM_TARGET_PATH=..

This basically tells it to put the repo directly in VirtualDirectory0 (as opposed to VirtualDirectory0\site), and then to deploy to VirtualDirectory0\site (as opposed to VirtualDirectory0\site\wwwroot).

This assumes that your repo contains a folder named wwwroot.

Some info on these paths here

4
votes

I found a solution that seems to work perfectly and allows a bit more control over what gets copied, overwritten, etc because it uses xcopy directly. Given a git project with wwwroot and myapp (in my case they are in the root) you can use a deployment batch file to copy those folders to the wwwroot and a folder above. The solution came from this article:

1.) 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 

2.) Commit, push, smile

0
votes

had the same issue referred to this post a couple of times did it wrong a couple of times but got it to work.

SOLUTION

  1. Using an ftp like filezila, ftp connect to your website and create a your app folder under the site folder, such as site/myapp
  2. on azure management portal select your azure website you want to deploy to
  3. under configuration tab scroll down to app settings
  4. set the key SCM_TARGET_PATH to ..\myapp
  5. TAKE NOTE OF THE forward slash \ NOT backslash /
0
votes

Please also try to put a dummy text file in the "wwwroot" under the project folder. This will make sure that the directory is created.