This Azure DevOps pipeline automates the process of building a Docker image, pushing it to an Azure Container Registry, and deploying it to an Azure Web App. The pipeline is triggered when changes are pushed to the main
branch of the repository.
- Trigger: The pipeline is triggered when changes are pushed to the
main
branch.
dockerRegistryServiceConnection
: Azure Container Registry service connection established during pipeline creation.imageRepository
: The name of the Docker image repository.containerRegistry
: The Azure Container Registry where the Docker image will be pushed.dockerfilePath
: The path to the Dockerfile.tag
: The unique tag for the Docker image, typically the Build ID.vmImageName
: The name of the agent VM image.
- Stage: Build
- Job: Build
- Uses an Ubuntu agent for building the Docker image.
- Builds and pushes the Docker image to the specified container registry.
- Deploys the image to an Azure Web App staging slot.
- Job: Build
-
Configure the variables in your Azure DevOps pipeline according to your specific project and Azure settings.
-
Ensure you have an Azure service connection in Azure DevOps to access Azure resources.
-
Set up the necessary environment, Dockerfile, and application code in your repository.
-
Push changes to the
main
branch to trigger the pipeline.
This Azure DevOps pipeline automates the process of building a Docker image, pushing it to an Azure Container Registry, and deploying it to Azure infrastructure. The pipeline is triggered when changes are pushed to the main
branch of the repository.
- Trigger: The pipeline is triggered when changes are pushed to the
main
branch.
tag
: The unique tag for the Docker image, typically the Build ID.vmImageName
: The name of the agent VM.- Other variables may be defined in group-specific variable groups.
-
Stage: Build
- Job: BuildAndTest
- Builds the Docker image.
- Runs unit tests and publishes test results.
- Copies ARM templates and publishes code coverage reports.
- Publishes Docker image to a container registry.
- Job: BuildAndTest
-
Stage: DeployToDev
- Deploys infrastructure to the Dev environment using ARM templates.
-
Stage: DeployToTest
- Deploys infrastructure to the Test environment using ARM templates.
-
Job: DeployInfrastructure
- Deploys infrastructure using downloaded ARM templates and parameters.
-
Configure the variables and parameter values in your Azure DevOps pipeline according to your specific project and Azure settings.
-
Ensure you have an Azure service connection in Azure DevOps to access Azure resources.
-
Set up the necessary environment, Dockerfile, application code, and ARM templates in your repository.
-
Push changes to the
main
branch to trigger the pipeline.
This Azure DevOps pipeline is designed to deploy code to a production environment. It consists of two stages: Build and DeployToProd.
- Triggers: The pipeline is triggered when changes are pushed to the
main
orproduction
branches of the repository.
-
Stage: Build
- Job: Build
- Copies necessary files to prepare for deployment.
- Uploads artifacts to the pipeline for deployment.
- Job: Build
-
Stage: DeployToProd
- Job: VMDeploy
- Deploys code to a production environment, specifically a Virtual Machine.
- Downloads artifacts from the build stage.
- Executes scripts to set up prerequisites and deploy the application.
- Job: VMDeploy
-
Configure your triggers to match your branching strategy and determine when the pipeline should run.
-
Customize the deployment scripts in the
DeployToProd
stage to match your deployment requirements. -
Ensure that the production environment (Virtual Machine) is set up with the necessary dependencies for your application.
-
Push changes to the
main
orproduction
branch to trigger the pipeline.
For more details on using this pipeline, refer to the official Azure DevOps documentation:
Mohamed Mahrous
This project is licensed under the MIT License - see the LICENSE.md file for details.