Amitay Strijevski
Amitay Strijevski

Reputation: 96

Continuous deployment with github and azure function project in visual studio 2017 preview

I am trying to set ci/cd from github to azure functions I created an Azure function project in git "https://github.com/AmitayStrijevski/AppFunctionTest".

I published it once through the visual studio and it worked perfect.

Then i connected it to the github ci/cd described here "https://learn.microsoft.com/en-us/azure/azure-functions/functions-continuous-deployment#continuous-deployment-requirements".

When pushing to git i can see it takes my code and "deploy" it but when i look at the the functions my new code is not there and the logs show the following message

"Found solution 'D:\home\site\repository\HeyArnold\HeyArnold.sln' with no deployable projects. Deploying files instead."

I spent more than a day on this and i will really appreciate help in this issue

I was able to use the github deployment when using an empty web site and setting the same folder structure generated by the azure portal This is still not solve my problem because i want to use Azure function project but i thought worth mentioning

Upvotes: 1

Views: 974

Answers (4)

Seb Nilsson
Seb Nilsson

Reputation: 26408

You can add a .deployment-file to the root of your repository and point Azure, and Kudu, to the correct project-path:

[config] project = src/PathToYourProject

Or you can add a Application settings in the Azure Portal with the key PROJECT and the value pointing to the correct project-path.

Upvotes: 0

Amitay Strijevski
Amitay Strijevski

Reputation: 96

After consulting with Microsoft support i recevied two files that needed to be put in the .sln folder and then git deployment will work

Be aware changing lines :: 1. Restore nuget packages :: 2. Build and publish With your solution and project actual name

  • .deployment

    [config] command = deploy.cmd

  • deployment.cmd

    @if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

    :: ---------------------- :: KUDU Deployment Script :: Version: 1.0.15 :: ----------------------

    :: Prerequisites :: -------------

    :: Verify node.js installed where node 2>nul >nul IF %ERRORLEVEL% NEQ 0 ( echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment. goto error )

    :: Setup :: -----

    setlocal enabledelayedexpansion

    SET ARTIFACTS=%~dp0%..\artifacts

    IF NOT DEFINED DEPLOYMENT_SOURCE ( SET DEPLOYMENT_SOURCE=%~dp0%. )

    IF NOT DEFINED DEPLOYMENT_TARGET ( SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot )

    IF NOT DEFINED NEXT_MANIFEST_PATH ( SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

    IF NOT DEFINED PREVIOUS_MANIFEST_PATH ( SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest ) )

    IF NOT DEFINED KUDU_SYNC_CMD ( :: Install kudu sync echo Installing Kudu Sync call npm install kudusync -g --silent IF !ERRORLEVEL! NEQ 0 goto error

    :: Locally just running "kuduSync" would also work SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd )

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Deployment :: ---------- echo Handling function App deployment with Custom script.

    :: 1. Restore nuget packages call :ExecuteCmd nuget.exe restore "%DEPLOYMENT_SOURCE%\FunctionAppVS2017_3Preview.sln" -MSBuildPath "D:\Program Files (x86)\MSBuild-15.3-preview\MSBuild\15.0\Bin" IF !ERRORLEVEL! NEQ 0 goto error

    :: 2. Build and publish call :ExecuteCmd "D:\Program Files (x86)\MSBuild-15.3-preview\MSBuild\15.0\Bin\MSBuild.exe" "%DEPLOYMENT_SOURCE%FunctionApp1\FunctionApp1.csproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="%DEPLOYMENT_TEMP%" %SCM_BUILD_ARGS% IF !ERRORLEVEL! NEQ 0 goto error

    :: 3. KuduSync IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" ( call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd" IF !ERRORLEVEL! NEQ 0 goto error )

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: goto end

    :: Execute command routine that will echo out when error :ExecuteCmd setlocal set CMD=%* call %CMD% if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%CMD% exit /b %ERRORLEVEL%

    :error endlocal echo An error has occurred during web site deployment. call :exitSetErrorLevel call :exitFromFunction 2>nul

    :exitSetErrorLevel exit /b 1

    :exitFromFunction ()

    :end endlocal echo Finished successfully.

Upvotes: 2

Garth Mason
Garth Mason

Reputation: 8001

I'm using VSTS rather than GitHub but you might still find this link here of use.

Using the tooling extension for Azure Functions in VS2017 Preview, along with the build steps described in this issue I've been able to get this CI pipeline going with an Azure functions project. Josh Carlisle has detailed the steps to get this up and running on his blog.

Upvotes: 0

Matt Mason
Matt Mason

Reputation: 2726

Check out <functionappname>.scm.azurewebsites.net/dev to see what files are actually deployed to the wwwroot folder.

I took a look at your github project and I noticed a few things: if you're using .cs files, you should be creating a precompiled function, which you can deploy directly from VS.

However, if you're instead using .csx files and want to be able to edit code from the functions portal, the structure you have is correct - just remove the solution and csproj files, as I believe they are confusing the deployment infrastructure

Upvotes: 2

Related Questions