Skip to content

Instantly share code, notes, and snippets.

@sondreb
Created August 31, 2020 20:15
Show Gist options
  • Save sondreb/a501fcba611c5d2eff1a1aa3762bae6d to your computer and use it in GitHub Desktop.
Save sondreb/a501fcba611c5d2eff1a1aa3762bae6d to your computer and use it in GitHub Desktop.
Most basic Azure DevOps pipeline and Dockerfile for ASP.NET Core with SPA (Angular/React)
azure-pipeline.yml:
name: Build and Push ($(Date:yyyyMMdd)$(Rev:.r))
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: dotnet publish --configuration 'Release' -o ./publish
displayName: 'dotnet publish'
- task: Docker@2
displayName: Docker Build and Push
inputs:
command: buildAndPush
containerRegistry: azureacr
repository: company/company-web
Dockerfile: '**/Dockerfile'
buildContext: '.'
addPipelineData: true
tags: |
$(Build.BuildId)
latest
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS runtime
EXPOSE 80
WORKDIR /app
COPY ./publish ./
ENTRYPOINT ["dotnet", "Company.Web.dll"]
@sondreb
Copy link
Author

sondreb commented Sep 3, 2020

To deploy the end results to Azure Web App for Containers, you simply add the following at the end of the pipeline:

- task: AzureWebAppContainer@1
  inputs:
    azureSubscription: 'YourAzureSubscriptionLinkInDevOps'
    appName: 'your-azure-web-app'
    containers: 'azureacr.azurecr.io/company/company-web:$(Build.BuildId)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment