Skip to content

Instantly share code, notes, and snippets.

@subhankars
Last active July 6, 2022 07:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save subhankars/6e9064cd7c03f8cdd939392d6736ea90 to your computer and use it in GitHub Desktop.
Save subhankars/6e9064cd7c03f8cdd939392d6736ea90 to your computer and use it in GitHub Desktop.
#This is a Build Deploy Pipeline for .NET 6 Web App to Azure App Service using Azure DevOps Pipeline
trigger:
- master
pool:
vmImage: ubuntu-latest
variables:
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
steps:
- task: UseDotNet@2
inputs:
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
inputs:
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
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'MinimalAPI'
#Publish it to the Azure App Service
- task: AzureWebApp@1
inputs:
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