This post is the second one in a series of three posts and will help you by creating a CI build for a Azure Function.
This blog post is totally written using the Azure Function Visual Studio template. Information and the Azure Function tools download are listed below:
- Finished Part 1 - Creating a Pre-Compiled Azure Function
- Azure Function Tools
- Visual Studio Team Services
The solution created in the previous steps needs to be added and committed to Source Control. When it is added open Visual Studio Team Services in the browser and navigate to the build tab.
When you do not have build within your project VSTS will show a large button to add a new build definition. Click this button (“New Definition” ) or use the smaller button within the top bar.
Next up is the template selection for the build definition. Select the Visual Studio Template.
This will create a Build definition with some default build steps. Save the the template as your build definition by clicking on “Save & Queue”
A queue build window will open with the default settings. Keep these settings to create a release build for every CPU type.
You will notice that this build will fail. This is because the “.funproj” is not known by the build agent (mainly because the template is still in preview). You can notice this by the following error.
MSFTPlayground Function\MSFT.Function\MSFT.Function.funproj(8,3): Error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AzureFunctions\Microsoft.AzureFunctions.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
The “.funproj” itself does not need to be build so to make the Build server run correctly we can and will exclude the project from the build. In order to get this done perform the following steps.
- Open Visual Studio and right click the solution.
- In the menu click on “Configuration Manager”
- Deselect the build checkbox for your Functions project. Do this for the debug and release configuration.
When the Function project is exclude from the build Commit the sources and queue the build again and you will see that this build will run successful.
Next post will be on: Deploying the Azure Function from the Build within VSTS.