New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI with App Service doesn't build new functions project #291

Closed
lindydonna opened this Issue May 16, 2017 · 22 comments

Comments

Projects
None yet
8 participants
@lindydonna
Contributor

lindydonna commented May 16, 2017

CI on App Service uses Kudu, which doesn't yet support the new functions project type. In addition, Kudu defaults to doing just a content publish for function apps. The Kudu issue is tracked here: projectkudu/kudu#2417

Our current recommended approach for CI/CD is to use VSTS with a VS 2017 build agent. You can then connect it to GitHub or a VSTS repo.

However, you need to make some manual modifications to the default App Service build template:

  • Use NuGet version 4.0
  • Change the msbuild arguments for the solution build step to the following:
    /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\output.zip" /p:DeployIisAppPath="Default Web Site"

I'll publish a blog post this week with a detailed walkthrough.

@BillRaymond

This comment has been minimized.

Show comment
Hide comment
@BillRaymond

BillRaymond May 16, 2017

To add some additional color, I posted the following question today. In Azure, you are led to believe you can connect the Function App to VSTS but that does not work either.

https://social.msdn.microsoft.com/Forums/en-US/ccdf0343-89f6-46b1-a358-0b9f23ed5fb0/cannot-integrate-vsts-with-azure-functions-using-cicd?forum=TFService

BillRaymond commented May 16, 2017

To add some additional color, I posted the following question today. In Azure, you are led to believe you can connect the Function App to VSTS but that does not work either.

https://social.msdn.microsoft.com/Forums/en-US/ccdf0343-89f6-46b1-a358-0b9f23ed5fb0/cannot-integrate-vsts-with-azure-functions-using-cicd?forum=TFService

@BillRaymond

This comment has been minimized.

Show comment
Hide comment
@BillRaymond

BillRaymond May 16, 2017

@lindydonna Thank you for getting back to me. Is CICD in the works for Azure Functions or is this something we should request?

BillRaymond commented May 16, 2017

@lindydonna Thank you for getting back to me. Is CICD in the works for Azure Functions or is this something we should request?

@lindydonna

This comment has been minimized.

Show comment
Hide comment
@lindydonna

lindydonna May 16, 2017

Contributor

@BillRaymond Yes, we're working on updating Kudu to the latest version of msbuild. Please follow projectkudu/kudu#2417 for updates.

Contributor

lindydonna commented May 16, 2017

@BillRaymond Yes, we're working on updating Kudu to the latest version of msbuild. Please follow projectkudu/kudu#2417 for updates.

@BillRaymond

This comment has been minimized.

Show comment
Hide comment
@BillRaymond

BillRaymond May 16, 2017

@lindydonna Thanks. I am following it now.

BillRaymond commented May 16, 2017

@lindydonna Thanks. I am following it now.

@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

Following on from #201 .. @joshdcar I did manage to get this working after a bit of trial and error (prior to seeing this issue).

As @lindydonna suggested in #291, in the build definition you need to select the VS2017 agent, and the latest NuGet version to restore packages.

In the release definition, I then used the 'Deploy Azure App Service` task, running on the 'Hosted VS2017' agent. Here I had to select the package/folder to the following so that it would deploy the correct file structure.

$(System.DefaultWorkingDirectory)/Your-Bulid-Name/drop/Your-Function-Project-Name/bin/Release/net461

Anyway, I'm not sure if that's the best/right way to do it, but it's working for me in our development envirnoment. I don't have a heap of experience in the VSTS Bulid/Release world so keen if there's better ways to get this working.

garthmason commented May 17, 2017

Following on from #201 .. @joshdcar I did manage to get this working after a bit of trial and error (prior to seeing this issue).

As @lindydonna suggested in #291, in the build definition you need to select the VS2017 agent, and the latest NuGet version to restore packages.

In the release definition, I then used the 'Deploy Azure App Service` task, running on the 'Hosted VS2017' agent. Here I had to select the package/folder to the following so that it would deploy the correct file structure.

$(System.DefaultWorkingDirectory)/Your-Bulid-Name/drop/Your-Function-Project-Name/bin/Release/net461

Anyway, I'm not sure if that's the best/right way to do it, but it's working for me in our development envirnoment. I don't have a heap of experience in the VSTS Bulid/Release world so keen if there's better ways to get this working.

@lindydonna

This comment has been minimized.

Show comment
Hide comment
@lindydonna

lindydonna May 17, 2017

Contributor

@garthmason You shouldn't have to do that, if you use the msbuild modification I mentioned. The default should pick up any zip files in the build output.

Contributor

lindydonna commented May 17, 2017

@garthmason You shouldn't have to do that, if you use the msbuild modification I mentioned. The default should pick up any zip files in the build output.

@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

@lindydonna thanks - I'm going to update my build configuration today using your msbuild modifications rather than what I'd tried yesterday. Appreciate your help!

garthmason commented May 17, 2017

@lindydonna thanks - I'm going to update my build configuration today using your msbuild modifications rather than what I'd tried yesterday. Appreciate your help!

@joshdcar

This comment has been minimized.

Show comment
Hide comment
@joshdcar

joshdcar May 17, 2017

@lindydonna thanks so much for the quick response. I got the build CI/CD up and running successfully on VSTS this evening with your workaround instructions. Thanks!

joshdcar commented May 17, 2017

@lindydonna thanks so much for the quick response. I got the build CI/CD up and running successfully on VSTS this evening with your workaround instructions. Thanks!

@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

I'm a bit stuck now - this might be a silly question but I've added the msbuild arguments but how do I set NuGet version to 4? I'm using the NuGet restore task, but I don't see a v4 option there.
Thanks again for your help

garthmason commented May 17, 2017

I'm a bit stuck now - this might be a silly question but I've added the msbuild arguments but how do I set NuGet version to 4? I'm using the NuGet restore task, but I don't see a v4 option there.
Thanks again for your help

@slideep

This comment has been minimized.

Show comment
Hide comment
@slideep

slideep May 17, 2017

@garthmason I started doing CI/CD following the mentioned arguments but at least with the build definition:

nuget_restore_task_step

slideep commented May 17, 2017

@garthmason I started doing CI/CD following the mentioned arguments but at least with the build definition:

nuget_restore_task_step

@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

@slideep thanks for that! I'll give it a shot right now
I didn't see those options, not shown when selecting version 1.* of the installer task.

garthmason commented May 17, 2017

@slideep thanks for that! I'll give it a shot right now
I didn't see those options, not shown when selecting version 1.* of the installer task.

@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

@slideep that's done the trick - thanks very much for your help!

garthmason commented May 17, 2017

@slideep that's done the trick - thanks very much for your help!

@slideep

This comment has been minimized.

Show comment
Hide comment
@slideep

slideep May 17, 2017

@garthmason glad it worked out for you! yup, it's right down there when you click 'Advanced' dropdown menu thingie. Me, I'm hitting Error MSB4062: The "CreateManifestFile" task error which could originate from private NuGet packages??? Have to investigate a bit more since continuous deployment from VSTS works just fine and app updates whenever I push changes to repo.

MSB4062 mentioned here:

2017-05-17T06:20:32.3985139Z   Creating "d:\a\1\a\TestFunctions.SourceManifest.xml" because "AlwaysCreate" was specified.
2017-05-17T06:20:32.3985139Z   Creating "d:\a\1\a\TestFunctions.Parameters.xml" because "AlwaysCreate" was specified.
2017-05-17T06:20:32.4364742Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(160,5): Error MSB4062: The "CreateManifestFile" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
2017-05-17T06:20:32.4364742Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(160,5): error MSB4062: The "CreateManifestFile" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\TestFunctions\TestFunctions.csproj]

slideep commented May 17, 2017

@garthmason glad it worked out for you! yup, it's right down there when you click 'Advanced' dropdown menu thingie. Me, I'm hitting Error MSB4062: The "CreateManifestFile" task error which could originate from private NuGet packages??? Have to investigate a bit more since continuous deployment from VSTS works just fine and app updates whenever I push changes to repo.

MSB4062 mentioned here:

2017-05-17T06:20:32.3985139Z   Creating "d:\a\1\a\TestFunctions.SourceManifest.xml" because "AlwaysCreate" was specified.
2017-05-17T06:20:32.3985139Z   Creating "d:\a\1\a\TestFunctions.Parameters.xml" because "AlwaysCreate" was specified.
2017-05-17T06:20:32.4364742Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(160,5): Error MSB4062: The "CreateManifestFile" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
2017-05-17T06:20:32.4364742Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(160,5): error MSB4062: The "CreateManifestFile" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\TestFunctions\TestFunctions.csproj]
@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

@slideep I haven't come across that error - but we aren't using any private NuGet packages, just the standard stuff so far.

garthmason commented May 17, 2017

@slideep I haven't come across that error - but we aren't using any private NuGet packages, just the standard stuff so far.

@joshdcar

This comment has been minimized.

Show comment
Hide comment
@joshdcar

joshdcar May 17, 2017

I put together a very simple walkthrough of getting a very basic Azure Function project up and running with VSTS. Nothing fancy here but I thought it might benefit someone visiting this thread. With the guidance from @lindydonna it was really a pretty quick process. Thanks again for the quick response to the request!

https://www.joshcarlisle.io/blog/2017/5/17/visual-studio-2017-tools-for-azure-functions-and-continuous-integration-with-vsts

joshdcar commented May 17, 2017

I put together a very simple walkthrough of getting a very basic Azure Function project up and running with VSTS. Nothing fancy here but I thought it might benefit someone visiting this thread. With the guidance from @lindydonna it was really a pretty quick process. Thanks again for the quick response to the request!

https://www.joshcarlisle.io/blog/2017/5/17/visual-studio-2017-tools-for-azure-functions-and-continuous-integration-with-vsts

@garthmason

This comment has been minimized.

Show comment
Hide comment
@garthmason

garthmason May 17, 2017

Great stuff @joshdcar - I'll be pointing my team at that blog post. Cheers!

garthmason commented May 17, 2017

Great stuff @joshdcar - I'll be pointing my team at that blog post. Cheers!

@BillRaymond

This comment has been minimized.

Show comment
Hide comment
@BillRaymond

BillRaymond commented May 18, 2017

Thank you @joshdcar!

@hnky

This comment has been minimized.

Show comment
Hide comment
@hnky

hnky commented May 30, 2017

Thanks @joshdcar

@afgreco

This comment has been minimized.

Show comment
Hide comment
@afgreco

afgreco Jun 14, 2017

By setting up my MSBuild arguments as explained here I am able to get a single .zip file with my azure functions projects bundled to it. My issue is, my solution has several different Azure Functions projects inside of it, and I need to create a single zip per function so that I can then individually deploy them each to their valid Azure Service. I can see in my build logs that it is trying to re-create the zip over and over, so I have to assume it is just merging each together, one after another.

I have tried every possible way I could think to public a new Zip per project, without any luck.

Below is an example, however MSBuild completely ignores [$(MSBuildProje‌​ctName)] and physically names my file [$(MSBuildProje‌​ctName).zip]:
/p:DesktopBuildPackageLocation="$(build.artifactstagingdirec‌​tory)$(MSBuildProje‌​ctName).zip"

Any help in how to tweak this so I get a new zip per single azure function project would be greatly appreciated.

afgreco commented Jun 14, 2017

By setting up my MSBuild arguments as explained here I am able to get a single .zip file with my azure functions projects bundled to it. My issue is, my solution has several different Azure Functions projects inside of it, and I need to create a single zip per function so that I can then individually deploy them each to their valid Azure Service. I can see in my build logs that it is trying to re-create the zip over and over, so I have to assume it is just merging each together, one after another.

I have tried every possible way I could think to public a new Zip per project, without any luck.

Below is an example, however MSBuild completely ignores [$(MSBuildProje‌​ctName)] and physically names my file [$(MSBuildProje‌​ctName).zip]:
/p:DesktopBuildPackageLocation="$(build.artifactstagingdirec‌​tory)$(MSBuildProje‌​ctName).zip"

Any help in how to tweak this so I get a new zip per single azure function project would be greatly appreciated.

@xtrsys

This comment has been minimized.

Show comment
Hide comment
@xtrsys

xtrsys Jun 14, 2017

Why not create separate MSBuild task for each project with different output? Also it's not mandatory to have it as single zip. AppService deployments accepts folder as well.

xtrsys commented Jun 14, 2017

Why not create separate MSBuild task for each project with different output? Also it's not mandatory to have it as single zip. AppService deployments accepts folder as well.

@afgreco

This comment has been minimized.

Show comment
Hide comment
@afgreco

afgreco Jun 14, 2017

@xtrsys I did spend a good amount of last night trying to get this to work with 'DesktopBuildPackageLocation' XML in the actual project files with limited success. It looked like it may work if I just get the correct syntax working. That was one item I was going to continue on today.

The other option was to add a Zip Extraction so that I could then link to a folder. Same thing, it looks like that could work once I get the correct syntax to locate the folder. Each try told me it could not extract because it cannot find the folder, despite it being the same path my LOG says it created the Zip under.

I am not sure if it will matter or not but there are a bunch of package files outside of the main project folder that gets created, and then I assume overwrote the second time the zip is created. Looking into the files, none seemed to be specific to the azure function projects though.

It takes about 20 mins to fully build / complete each time I try something new so I was limited to how much I could try last night before 4am quickly rolled around.

afgreco commented Jun 14, 2017

@xtrsys I did spend a good amount of last night trying to get this to work with 'DesktopBuildPackageLocation' XML in the actual project files with limited success. It looked like it may work if I just get the correct syntax working. That was one item I was going to continue on today.

The other option was to add a Zip Extraction so that I could then link to a folder. Same thing, it looks like that could work once I get the correct syntax to locate the folder. Each try told me it could not extract because it cannot find the folder, despite it being the same path my LOG says it created the Zip under.

I am not sure if it will matter or not but there are a bunch of package files outside of the main project folder that gets created, and then I assume overwrote the second time the zip is created. Looking into the files, none seemed to be specific to the azure function projects though.

It takes about 20 mins to fully build / complete each time I try something new so I was limited to how much I could try last night before 4am quickly rolled around.

@lindydonna

This comment has been minimized.

Show comment
Hide comment
@lindydonna

lindydonna Jun 15, 2017

Contributor

@afgreco Have you seen this blog post? It's a much simpler workflow: https://blogs.msdn.microsoft.com/appserviceteam/2017/06/01/deploying-visual-studio-2017-function-projects-with-vsts/

I'm closing this issue as Kudu now supports the new Functions project type.

Contributor

lindydonna commented Jun 15, 2017

@afgreco Have you seen this blog post? It's a much simpler workflow: https://blogs.msdn.microsoft.com/appserviceteam/2017/06/01/deploying-visual-studio-2017-function-projects-with-vsts/

I'm closing this issue as Kudu now supports the new Functions project type.

@lindydonna lindydonna closed this Jun 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment