This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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