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)
Continuous Deployment (CD)
- 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.
Recommended by LinkedIn
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