To get started with Azure DevOps create an account as I described here. I am going to use my public Azure DevOps project here and the application as start point, we created here.

Clone the repo and open it in the Visual Studio or Visual Studio Code. Here you can read how to download both.

Right click on the solution node and click on Add -> New Item...

New Item

There is no yaml file template yet but just find a text file and rename the extension

New YAML file

Call it f.ex. api-build-pipeline.yaml

Then paste the following code

  buildConfiguration: 'Release'

- script: dotnet restore
  displayName: 'dotnet restore'

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build with following configuration $(buildConfiguration)'

- script: dotnet test $(Parameters.TestProjects) --configuration $(BuildConfiguration)
  displayName: 'dotnet test'

- task: DotNetCoreCLI@2
  displayName: Publish and zip WebApplication to output
    command: publish
    publishWebProjects: False
    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
    zipAfterPublish: True

- task: PublishBuildArtifacts@1
  displayName: Publish artifacts

This is exactly representation of this

Save everything and push the changes. You can take a look at the complete code here.

Now we are going to create a new build pipeline and use this yaml file.

Navigate to Pipelines -> Builds


Click on + New

New build pipeline

Choose New build pipeline

Azure Repos Git

We are hosting code in the Azure DevOps repo that's why choosing Azure Repos Git

Select a repository

Choose your repo, I am using MyVeryFirstAPIWithYaml.

Configure your pipeline

Now we have a couple of choices. Azure DevOps recommends you to use the ASP.NET Core template. We are already created  yaml file for our solution, that's why choosing Existing Azure Pipelines YAML file

Now you have to paste in the name of the yaml file we created previously. The dropdown unfortunately doesn't work yet, but I am sure Azure DevOps team will fix it.

Click on Continue.

Click Run.

Create pipeline

Now to save your pipeline you have to click on Run. By default the name of the build pipeline become the name of the repo. If you are not agree go to Pipelines->Builds

All pipelines

And click on small folder icon. Click on you build definition and Edit

Edit build pipeline

Now click on dots

YAML representation 

And choose either Triggers or Variables.

Click on YAML

Build Settings

Now  you can change the Name, the Agent pool and YAML path. It's interesting by default Azure DevOps chose to build our solution using Ubuntu box. If you prefer something else just choose it.

Agent pools

Usually you choose Hosted VS2017 if you kind of used to windows build environment, but with .NET Core it doesn't matter. This is the power of being cross platform.

I will slightly change the name to MyVeryFirstAPIWithYaml-CI. CI means Continuous Integration and means that I want this build triggered each time I push the code.

Create Azure DevOps account

My public Azure DevOps project DotNetCore

Create first .NET Core API

My MyVeryFirstAPIUsingCLI public repo

Get started with .NET Core