Azure DevOps CI/CD

Azure DevOps CI/CD

Just sharing how to create CI/CD in Azure DevOps, hoping you find it helpful and saves you time. I assume that you already have a project and repo in DevOps and just want to create a CI/CD pipeline. For the sample pipeline below, I am targeting Azure Web App slot for the deployment.

Continuous Integration (CI)

  • Create a Pipeline and select the following configuration: [Connect] Azure Repos Git, [Select] <select a repository>, [Configure] ASP.NET Core (.NET Framework)
  • Click ‘Save’ and the continuous integration configuration is done. You may also click ‘Save and run’ to immediately run the pipeline. Every time you push changes into the repo, the pipeline will automatically run. Note that if you have a unit test project under your solution, the test cases are run by the VSTest task.
  • If you don’t want to build the solution every time the repo is updated, you may change the trigger.

No alt text provided for this image

Continuous Deployment (CD)

  • Edit the pipeline created above and add the following lines:

- task: PublishBuildArtifacts@

  inputs:

    PathtoPublish: '$(Build.ArtifactStagingDirectory)'

    ArtifactName: 'drop'

    publishLocation: 'Container'

 

- task: AzureRmWebAppDeployment@4

  inputs:

    ConnectionType: 'AzureRM'

    azureSubscription: '<enter subscription here>'

    appType: 'webApp'

    WebAppName: '<enter web app name here>'

    deployToSlotOrASE: true

    ResourceGroupName: '<enter resource group name here>'

    SlotName: '<target slot name>'

    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

    enableCustomDeployment: true

    DeploymentType: 'webDeploy'

    RenameFilesFlag: false        

If you want to add them via a UI, you may select the ‘Publish build artifacts’ and ‘Azure App Service deploy’ for PublishBuildArtifacts and PublishBuildArtifacts respectively. Just change the value of packageForLinux as the UI has a different value by default.

  • Click ‘Save’ and the Continuous integration configuration is done. Every successful build will be automatically deployed to the target Azure Web App slot.

Artifacts Feeds

If you are using a private nuget server, you will have to create a connection to it first. Go to project settings and click the Service connection. Create a connection from there using the Nuget service connection. From Artifacts, click Connect to Feed and follow the instructions.

You may need to add the public nuget package source into the nuget.config file if you are also using public nuget packages:

<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />

If you have a local nuget package, you may create a feed first from the Artifacts page.

Once the feed is configured, you need to edit the pipeline and update the NuGetCommand:

- task: NuGetCommand@

  inputs:

    command: 'restore'

    restoreSolution: '$(solution)'

    feedsToUse: 'config'
        

Run the pipeline to test your configuration

To view or add a comment, sign in

More articles by Lord Salas

  • .Net Core 5 Microservice + Docker with Azure AD

    I would like to share how I created Microservice structure using Docker, Ocelot, .NET Core (.

  • URL Shortener Service in .NET Core

    Let us talk about URL Shortener service. You maybe already using it but knowing what is behind may surprise you how…

  • Working with Azure Service Bus Queues in C#

    I have been using Service Bus for a while and I would like to share my experience. One of my project is using service…

  • Embed Power BI Report into your .NET Core Application

    For a while I have been searching for a way to embed Power BI reports in to my application and I found this Microsoft…

  • Remote Desktop Application in C#

    The idea of this project is to be able to setup your own Remote Desktop application for personal and commercial use…

  • Integrating ReactJS into ASP.NET

    Once upon a time I was thinking of integrating ReactJS into my ASP.NET project.

  • SQL Server 2017 for Linux

    Experience the power of SQL Server in Linux. It is not hard to setup as you might think.

    1 Comment

Others also viewed

Explore content categories