.NET Core 3.1 - Build, Test and Deploy CI/CD Pipeline for Azure Web Apps (Linux)
.Net Core 3.1 LTS is available from December so most of you will probably update over time your existing apps in order to benefit for longer support at least until .Net Core 5.0 is available.
If you have not upgraded your projects yet please do so. Also keep an eye on the Microsoft .Net Core release lifecycles.
Version | Original Release Date | Latest Patch Version | Patch Release Date | Support Level | End of Support |
---|---|---|---|---|---|
.NET Core 3.1 | December 3, 2019 | 3.1.3 | March 24, 2020 | LTS | December 3, 2022 |
.NET Core 3.0 | September 23, 2019 | 3.0.3 | February 18, 2020 | EOL | March 3, 2020 |
.NET Core 2.2 | December 4, 2018 | 2.2.8 | November 19, 2019 | EOL | December 23, 2019 |
.NET Core 2.1 | May 30, 2018 | 2.1.17 | March 24, 2020 | LTS | August 21, 2021 |
.NET Core 2.0 | August 14, 2017 | 2.0.9 | July 10, 2018 | EOL | October 1, 2018 |
.NET Core 1.1 | November 16, 2016 | 1.1.13 | May 14, 2019 | EOL | June 27 2019 |
.NET Core 1.0 | June 27, 2016 | 1.0.16 | May 14, 2019 | EOL | June 27 2019 |
If you are creating now a new project or just upgrading an old one, you will want to have it on a CI/CD pipeline in Azure in order to speed up deployment and also automate the whole end to end process.
Bellow you will find a basic YAML configuration in order to get you started.
# ASP.NET Core # Build and test ASP.NET Core projects targeting .NET Core. # Add steps that run tests, create a NuGet package, deploy, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core #set the trigger to the branch you want to use for Continous Integration trigger: - master pool: vmImage: 'ubuntu-latest' variables: buildConfiguration: 'Release' steps: #The default build container still comes by default with .net core 2.2 #Make sure you use the need version and apply it bellow. use 3.1.x for latest - task: UseDotNet@2 inputs: packageType: 'sdk' version: '3.1.x' #Build the source code - task: DotNetCoreCLI@2 displayName: Build inputs: command: 'build' projects: "**/*.sln" arguments: '--configuration $(buildConfiguration)' #run Tests - task: DotNetCoreCLI@2 displayName: Test inputs: command: test projects: '**/*tests/*.csproj' arguments: '--configuration $(buildConfiguration)' #If you have only one web project you can remove the Project variable and use publishWebProjects: true #In case you have a more advanced setup I recoomed specifying projects path - task: DotNetCoreCLI@2 displayName: Publish inputs: command: 'publish' projects: "**/*.sln" publishWebProjects: false arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: True #Upload the generated artifact to the pipeline history - task: PublishBuildArtifacts@1 displayName: Upload artifact inputs: pathtoPublish: '$(Build.ArtifactStagingDirectory)' artifactName: 'Your-Artifact-Name' #Deploy to Azure Web APP - task: AzureRmWebAppDeployment@4 displayName: Deploy inputs: ConnectionType: 'AzureRM' azureSubscription: 'Service-connection-name' appType: 'webAppLinux' WebAppName: 'Your-WebApp-Name' packageForLinux: '$(System.ArtifactsDirectory)/**/*.zip'
Make sure you have an Azure Resource Manger connection to your subscription in /_settings/adminservices from your dev.azure.com project URL and replace the value above in azureSubscription with the service “Service connection name” you create. Also change the WebAppName to the name of your web app from Azure
After you run the pipeline, if there are no errors you should also be able to see the status of the deployment in Deployment Center of your web app.