Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The 'dotnet publish' command line skips deployment to Azure Functions

I'm setting up some DevOps for my site, and so far I've used the following command for deployment on two ASP.NET Core apps, with success:

dotnet publish ProjectName.csproj /p:PublishProfile="PublishProfileName" /p:Password=password

I've just created an Azure Function, using the V2 runtime and .NET Core 2.1, as suggested for all new projects (see here https://azure.microsoft.com/en-us/blog/introducing-azure-functions-2-0/), but if I use the same command, I find that it only publishes it to a local folder and doesn't seem to deploy the project to Azure.

If I use the MSBuild equivalent, it seems to also miss out the deployment stage.

I'm guessing its to do with the project type in some way not having the appropriate build targets, but I'm not sure how to track this further.

I can download the publish settings from Azure, import them into Visual studio and publish through VS, so it seems like if the VS path works, this might be a regression or bug in the tooling somewhere, rather than something unsupported?

I'm using:

  • Visual Studio 15.8.8 +28010.2048
  • Azure Functions and Web Jobs Tools 15.9.02046.0

If I shouldn't be using dotnet publish with Azure functions, what should I be using instead for command line CD? I've seen references to the Azure Function CLI tools, but I'd prefer not to have to install a package manager on our build agents if it can be done through other tooling.

like image 783
Andy Avatar asked Oct 29 '18 14:10

Andy


People also ask

What does dotnet publish command do?

Description. dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension.

Which of the following command will publish .NET Core application?

Publishing Self-Contained Framework Independent NET Core Application. Now we are going to execute the following command: dotnet publish –framework netcoreapp2. 2 –runtime linux-x64 –self-contained true.

Which command is used to publish .NET application as a self contained app to create a Windows 64 bit executable?

Use the dotnet command to start the appdll> command to start your app. . NET Core 2.1 SDK doesn't produce platform-specific executables for apps published framework-dependent.

What is the difference between dotnet build and publish?

Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it.


Video Answer


3 Answers

In the end, with the help of the answers and comments (thanks all), I have an MSBuild command line that is working to deploy my .NET Core 2.1 Function project:

msbuild /p:DeployOnBuild=True /p:PublishProfile=somename.pubxml /p:Configuration=Release

It is, however, worth noting the following:

General .NET Core publishing notes

  1. If you miss-spell the publish profile name, it will silently skip deployment (no warning or error).

Differences between ASP.NET Core and .NET Core Functions deployment

  1. If you use 'dotnet publish', it will always skip deployment.

  2. If you don't specify /p:DeployOnBuild=True, it'll skip deployment.

like image 97
Andy Avatar answered Oct 20 '22 16:10

Andy


If you do not want to have "a package manager" on your build agents you have to option to make a zip deploy of your function app. Details can be found on the MSDN here:

https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#rest

like image 26
Sebastian Achatz Avatar answered Oct 20 '22 15:10

Sebastian Achatz


Try the Azure CLI instead: https://learn.microsoft.com/en-us/cli/azure/functionapp/deployment?view=azure-cli-latest

or the function core tools: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local#publish

like image 21
Josh Avatar answered Oct 20 '22 16:10

Josh