Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure functions github deployment from subfolder

I'm using Azure functions with GitHub deployment. I would like to place the function in src/server/functionName/ within the repo, but the deployment works only if the function is placed directly in functionName/

How do I deploy functions that are placed in subdirectories?

The documentation states

your host.json file and function folders should be directly at the root of what you deploy.

but "should" doesn't mean "must", right?

What I tried:

  • Various combinations of locations of host.json and function.json
  • In host.json I set routePrefix but it seems to affect only the function's URL: "http": { "routePrefix": "src/server" },
like image 614
Amadeusz Wieczorek Avatar asked Nov 10 '16 09:11

Amadeusz Wieczorek


1 Answers

There are a few ways you can customize the deployment process. One way is by adding a custom deployment script to your repository root. When a .deployment script exists Azure will run that script as part of the deployment process as detailed here. E.g. you can write a simple script that copies the files and directories from your sub directory \src\server to the root, e.g.:

@echo off
echo Deploying Functions ...
xcopy "%DEPLOYMENT_SOURCE%\src\server" %DEPLOYMENT_TARGET% /Y /S

If you don't want to commit a .deployment file to your repo and your requirements are relatively simple, you can also do this via app settings by adding a PROJECT app setting to your function app with the value being your sub directory, e.g. src\server.

like image 182
mathewc Avatar answered Sep 23 '22 08:09

mathewc