Skip to content

Instantly share code, notes, and snippets.

Last active July 6, 2022 07:23
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#This is a Build Deploy Pipeline for .NET 6 Web App to Azure App Service using Azure DevOps Pipeline
- master
vmImage: ubuntu-latest
buildConfiguration: 'Release'
dotNetFramework: 'net6.0'
dotNetVersion: '6.0.x'
targetRuntime: 'linux-x64'
azureSPNName: 'YOUR-SPN-NAME' #get it from your AzureDevOps portal
azureAppServiceName: 'Your-Azure-AppService-Name' #get it from your Azure portal
# Build the app for .NET 6 framework
- task: UseDotNet@2
version: $(dotNetVersion)
includePreviewVersions: true
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'Build .NET 6 Application'
# Publish it as .NET 6 self-contained application for linux runtime
- task: DotNetCoreCLI@2
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --framework $(dotNetFramework) --runtime $(targetRuntime) --self-contained --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
# Package the file and uploads them as an artifact of the build
- task: PublishPipelineArtifact@1
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'MinimalAPI'
#Publish it to the Azure App Service
- task: AzureWebApp@1
appType: webAppLinux
azureSubscription: $(azureSPNName) #this is the name of the SPN
appName: $(azureAppServiceName) #App Service's unique name
package: $(Build.ArtifactStagingDirectory)/**/*.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment