0
votes

Deploying a .NET Core 3.1 API Application to an Azure WebApp fails when using DevOps CI/CD Release Pipeline but succeeds when Publishing from Visual Studio

Create .NET Core 3.1 Api App

enter image description here

enter image description here

enter image description here

enter image description here

Create Azure Web App

Create a new resource of type “Web App”

enter image description here

enter image description here

Publish from Visual Studio

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Ok, so that works, now here's what happens when trying to deploy using DevOps CI/CD Release Pipeline..

Deploy via DevOps CI/CD

… create another Web App resource junk-devops-cicd ...

enter image description here

deploy via ci/cd pipeline

enter image description here

Create the Build Pipeline

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Create the Release Pipeline

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

So it fails going through CI/CD pipeline. But not VS Publish Manager

enter image description here

2

2 Answers

-1
votes

Your .net core application build task is wrong. i guess solution is not getting build successfully . try visualstudio build instead of netBuild enter image description here

And make sure your Artifact Build directory path been set correctly. root path should be $(Build.ArtifactStagingDirectory)

1
votes

If the first pipeline you created is a CI pipeline (Build pipeline) you need to select the "ASP .net" template not the "Azure web App". this pipeline will restore nuget,build and publish the artifact of your app in the artifact store of AzureDevops. Then your release pipeline will get this artifact and deploy it into Azure.

the "Azure web App" template is a CI/CD template.

I think the mistake you have mad is deleting some essentials steps for building a package, "Use Nuget" and "Nuget restore".

To build an artifact correctly you need to have those steps: Asp .net build pipline