Skip to content

Instantly share code, notes, and snippets.

@mithunshanbhag
Created September 29, 2021 12:55
Show Gist options
  • Save mithunshanbhag/3f44cdad7449ef3efca74355d8a2dfb8 to your computer and use it in GitHub Desktop.
Save mithunshanbhag/3f44cdad7449ef3efca74355d8a2dfb8 to your computer and use it in GitHub Desktop.
Twitter-thread-app-service-deployment
stages:
- stage: build
jobs:
- job: build
steps:
- script: dotnet publish -c ${{parameters.buildConfiguration}} -o ./publish
displayName: dotnet publish
workingDirectory: $(Build.SourcesDirectory)/CloudSkew.API
# publish the pipeline artifact
- task: PublishPipelineArtifact@1
displayName: publish artifact
inputs:
artifact: dist
targetPath: $(Build.SourcesDirectory)/CloudSkew.API/publish
- stage: test
jobs:
- job: test
- stage: deploy
# don't execute this stage if triggered via pull-request.
condition: and(succeeded(), ne(variables['build.reason'], 'PullRequest'))
displayName: deploy to ${{parameters.environment}} environment
jobs:
- deployment: deploy
displayName: deploy to ${{parameters.environment}} environment
environment: ${{parameters.environment}}
strategy:
runOnce:
deploy:
steps:
# Let's now download the artifact we published earlier.
# Note: Artifacts are the only mechanism via which a stage can consume the
# output of an earlier stage
- task: DownloadPipelineArtifact@2
displayName: download artifact
inputs:
artifactName: dist
targetPath: $(Build.SourcesDirectory)/CloudSkew.API/publish
# stop app service
- task: AzureAppServiceManage@0
displayName: stop app service
inputs:
azureSubscription: ${{parameters.azureSubscription}}
action: 'Stop Azure App Service'
webAppName: ${{parameters.webAppName}}
resourceGroupName: ${{parameters.resourceGroupName}}
# deploy to app service
- task: AzureRMWebAppDeployment@4
displayName: deploy to app service
inputs:
azureSubscription: ${{parameters.azureSubscription}}
appType: webAppLinux
webAppName: ${{parameters.webAppName}}
resourceGroupName: ${{parameters.resourceGroupName}}
package: $(Build.SourcesDirectory)/CloudSkew.API/publish
removeAdditionalFilesFlag: true
excludeFilesFromAppDataFlag: true
# start app service
- task: AzureAppServiceManage@0
displayName: start app service
inputs:
azureSubscription: ${{parameters.azureSubscription}}
action: 'Start Azure App Service'
webAppName: ${{parameters.webAppName}}
resourceGroupName: ${{parameters.resourceGroupName}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment