When I deploy my Azure Function project to my Function App based on the v2 runtime, the binding extensions my project depend on (Azure Storage in my case), are not automatically created.
I deploy my project with an extensions.csproj file on the root, but after deploying I have to manually run the following command to create a bin and obj folder at wwwroot.
dotnet build extensions.csproj -o bin --no-incremental --packages D:\home\.nuget
If I understand correctly, this should happen automatically.
For deployment by CLI func azure functionapp publish
Function core tools use zip deployment to deploy functions, in this way, kudu doesn't build project by default. To enable the feature, set SCM_DO_BUILD_DURING_DEPLOYMENT to true in Application settings on portal.
As for why the default setting is false, zip deployment usually requires the content to be deployed including all related files hence there's no need to build again.
For Azure function core tools, we usually use command func extensions install to register extensions for input/output binding when extensions are not installed automatically like we create trigger from template. This is why command func start and func azure functionapp publish doesn't build extensions.csproj, extensions are supposed to be installed before we run or publish functions.
Update for DevOps deployment
With Azure pipeline, we need to build extensions.csporj before archive files. Add a .NET Core build task, arguments are -o bin.
If you want kudu to build project, go to Deployment Center under Platform features. Choose VSTS as a CI repository and kudu will build and deploy project for you.
When using Visual Studio, you'll be referencing the extension packages directly from your project in order to use their attributes and other types, so Visual Studio handles the installation process, but registration still needs to be performed.
This is handled by a custom build task, added by the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator NuGet package, which must be explicitly referenced (this will be automatically brought in by the SDK/Visual Studio tools in a future update).
These are the steps you must follow to use the CosmosDB extension mentioned in our previous example:
1.Add a reference to the Microsoft.Azure.WebJobs.Extensions.Storage NuGet package
2.Add a reference to the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator
3.Build the project
For more details, you could refer to this article.
Related
I have a simple executable, that I have build and unittested in a build pipeline.
now I want to install it on some test machines and run some tests on the app, before releasing it to production. (eventually I hope to automate the tests with specflow, but that is the next step)
So basically I have an helloworld.exe build, that I want to be installed from a pipeline to at test agent computer.
I think clickonce is the optimal option, but am unsure how to set it up on azure devops. (we use a server on premises)
Msbuild has Publish target to build and publish the ClickOnce application. It will generate the setup.exe you want. Please check document: Create and build a basic ClickOnce application with MSBuild. In release pipeline you can use msbuild task or Visual Studio Task with Publish target(/t:Publish as argument).
Then you'll get one app.publish folder where the files you want exist there:
This folder can be used for your further deployment.
Here is a ticket you can refer to .
In addition, azure devops Marketplace provides some extension: ClickOnce Packager, ClickOnceMore DevOps Pipeline Task.
Is there a way of having my Azure WebJob automatically deploy without needing to right click and select "Publish as Azure WebJob" every time? i.e. when I check-in my solution it is automatically deploy to the Azure Portal webjob section
While I tried to accomplish this, I found out that there is no tooling support for dotnet core projects as of now. The proposed webjobs.props/ msbuild solutions are all dotnet framework specific.
However I also found out that a webjob can be anything that's executable on the local machine (could be node.js or just a batch command).
The key is to understand how WebJobs are recognized by the host:
A WebJob on a Windows host is (by what I gathered from experimenting with it) just a run.cmd file that contains instructions on how to start the webJob. For dotnet core that would be dotnet MyDll.dll %* (%* to pass arguments for output redirection etc. down from the host).
Now depending on wether the job is continuous or triggered the run.cmd file needs to be located either at app_data/jobs/continuous/[NameOfJob] or app_data/jobs/triggered/[NameOfJob]. For the triggered job you could also add a schedule using a settings.job file like described here.
If there is a run.cmd at the proper location it will be recognized as a WebJob
Now to deploy a webjob using VSTS regardless of the runtime framework follow these steps:
Build/Publish your WebJob if necessary to get the executables
Add a run.cmd file next to your webjob executables that contains the proper startup instructions. You could also add settings.job here if needed.
Create the folder hierarchy app_data/jobs/[triggered/continuous]/[nameOfJob] and copy your executables into the lowest folder. Make sure run.cmd is directly under the [nameOfJob]/ directory
Zip the app_data folder so that the zip-package contains the entire hierarchy
Publish your zip file using the normal Azure App Service Deployment task (just like deploying the web app)
And that's it.
Yes you can.
Brady Gaster has written about this on a blog post (haven't tried it myself).
From what I gather, the TL;DR; summary is the following:
add a file named webjobs.props to the properties folder of the Web Application Project or Console Application you’re publishing
After that, edit the file so the ManagementCertificate, SubscriptionId and PublishSettingsPath are filled with correct data.
Now you should be able to publish the files using the command
msbuild WebJobDemo.Web.csproj /p:DeployOnBuild=true /p:PublishProfile=WebJobDemo /p:VisualStudioVersion=12.0 /p:Password=asdfasdf
(Note, post is written for VS2013)
Afterwards you should see something like this.
You could of course automate this in VSTS (or any other build/deployment tool for that matter) whenever something is checked in to your repository.
A (rather complete) answer on how to do this in VSTS via the command-line can be found in this answer: https://stackoverflow.com/a/45703975/352640
You can do it through Continuous Integration Build (trigger the build once check in).
Regarding deploy WebJob, you can generate a package through Visual Studio Build task with /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)" argument.
Then deploy it through Azure App Deployment task.
More information: Deploying and Schedule Azure WebJobs from VSTS to Azure Web App
In Visual Studio in order to enable automatic WebJobs deployment together with a Web project right-click the Web project in Solution Explorer, and then click: Add > Existing Project as Azure WebJob and create your WebJob.
More details can be found in an article by MS - webjobs-dotnet-deploy-vs
I'm currently using the 'Add Azure WebJob' functionality as part of the Azure SDK in Visual Studio to add a WebJob into a Web App that gets deployed to Azure. I use a custom .proj file for my build, and when I build using msbuild on the command line, the package that gets generated correctly includes the webjob. However, when I use TFS to build the custom .proj file, WITH EXACTLY THE SAME COMMAND the webjob doesn't get included. For whatever reason, the publish targets for the webjob in the targets file provided by Microsoft.Web.WebJobs.Publish nuget package simply don't get executed. Has anybody run across anything like this before ?
I'm having some trouble deploying an Azure Web Service using the new Team Build that is available at Visual Studio Online. When the solution have been built successfully, the deployment task tries to find the CsPkg and the CsCfg, which fails.
How do I specify the "Path of CsPkg/CsCfg under the default artifact directory" that is required? Do I have to specify some MSBuild arguments?
You can use the $(build.stagingDirectory) variable in the CsPkg/CsCfg fields. This will be the root of your repo. Your binaries will be at some location under there. E.g. $(build.stagingDirectory)\*.cspkg and
$(build.stagingDirectory)\*.cscfg
There's a huge list of built-in variables on MSDN.
You may also have to build your cloud service project with the MSBuild argument /t:Publish
I just checked: If you use the "Cloud Service" deployment template, all of this stuff is automatically filled in for you, including the paths.
For a Azure cloud service, there're typically 2 configuration files.
Serviceconfiguration.Cloud.cscfg
ServiceConfiguration.Local.cscfg
When I press F5 in Visual Studio to run with local development environment, the Local one will be used.
When I publish it to Azure with Visual Studio, the Cloud one will be used.
Now I am building my cloud service with Team Foundation Build. Where can I configure which cscfg file the build engine should use?
Add
With the publish wizard in VS2013, I can choose the config file to use:
But when I rebuild the cloud project, it always use the *.Local.cscfg file to generate the final
ServiceConfiguration.cscfg. Like below:
How can I make my local build use the .Cloud.cscfg file? My purpose is to config TFS build process to use the right cscfg file.