How to Deploy CI/CD Flow From Azure to AWS?

Deploy CI/CD Flow From Azure to AWS
March 30, 2022

What is CI/CD?

  • CI/CD stands for Continuous Integration, and continuous deployment bridges the development and operational environments.
  • It helps facilitate the process, the application release, build, and deployment of the latest features to the market with many checks without any manual intervention or avoiding long human hours to validate the code and proceed for final deployments.

What is Azure DevOps?

  • Azure DevOps Server is a Microsoft product that provides version control, reporting, requirements management, project management, automated builds, testing, and release management capabilities. It covers the entire application lifecycle and enables DevOps capabilities.

What is AWS CodeDeploy?

  • CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services.

What is our Use Case?

  • The current setup involves Continuous integration with Azure DevOps and Continuous Deployment with AWS Code Deploy.
  • The development team is working and committing their code to AZURE Repos, and the Application infrastructure is set up and running AWS.
  • The idea is to Setup a pipeline for all the Micro-services on Azure linked up with eh Azure-Repos, and final build artifacts will be pushed to S3 on successful build and code deployment to absorb the artifacts from S3 using AWS lambda and deploy onto production EC2 workloads.

Configuring Azure pipeline with Azure Repo on Microsoft Azure DevOps.

  • Deployment Process.
    • The developer pushes the code into the Azure repository service, which triggers the Azure pipeline as to how the azurepipline.yml file is structured.
    • Once the Azure pipeline is triggered, it will build the entire dotnet application code, artifact the entire application into zip files, and drop them to S3.
    • An IAM user has been created and used on the Azure pipeline to push the artifact from the Azure pipeline to AWS S3, and based on the date of deployment, the folder structure gets created on S3.
    • An AWS toolkit is installed on the Azure pipeline, which offers the option to dump the artifact to S3.
  • AWS Credential Setup.
    • Specifies the AWS credentials to be used by the task in the build agent environment.
    • In the task configuration, you can specify credentials using a service endpoint (of type AWS).
    • Once the Access key and Secret access keys are added to the AzureDevops configuration, the pipeline will have access to the AWS resources with permissions provided to the user’s keys.
  • AWS code deploys agent installation on the Servers
    • When an autoscaling group is used to achieve high application availability for end users for automating deployment on ASG servers, we need to install the code to deploy the agent.
    • To install the agent on every new server that the AWS autoscaling group launches, we need to use the user data in the Launch template/Launch configuration.
    • So, the user data helps install the AWS code deploy agent during the server boot time and keeps the machine ready for future deployments.
  • Click on the new pipeline setup on the Azure pipelines page, which helps show the version control configuration details. In this case, it is Azure Repos.
  • Once the Azure Repos Git YAML is selected, click on the classic editor, which leads to a YAML- based pipeline setup webpage.
  • Now select the template based on the type of application that needs to be built. In our case, the application is developed on dotnet core. We can choose ASP.Net Core.
  • It helps fetch the ASP.net core details as YAML to build the dotnet core application.
  • Once the details are automatically added to YAML by Azure, relevant build changes and configurations can be made to build the application.
  • Next, we need to add the details of the AWS S3 bucket to store the artifacts to trigger an AWS CodeDeploy to deploy the latest changes.
  • Fill in the relevant AWS S3 bucket details to store the artifacts with source folders in case they present on any existing bucket.
  • If the given AWS S3 bucket name and source folder details were not found. Azure pipeline will automatically create the S3 bucket and mentioned source folders on the fly during pipeline run.

Create an AWS CodeDeploy Service with added details of the EC2 instance. By creating an application with compute platform set to Ec2/On-premise.

  • Once the application is created, start creating a deployment group for microservice with deployment group name and service role containing permissions for code deploy service to deploy the resources on EC2.
  • Choose the deployment type as In-place with Environment configuration set to Autoscaling groups as we run the application with scalability across all Availability zones.
  • Set the deployment settings to where deployment configurations need to be set to HalfAtATime. Because we don’t want to lose all the instances at a time for the deployment and become a cause for downtime.
  • Set the load balancer details by checking the box and provide the load balancer name, which serves traffic for the micro-service in the deployment group.
  • Add a deployment trigger with the SNS topic as a trigger point to let the teams know the status of the deployment.
  • Enable the Deployment Rollback by checking the Roll back when a deployment fails So, any failure deployments will be reported to the teams with the above SNS trigger, and deployment will be rollbacked.
  • previous successful revision with the artifacts that are store in the S3 bucket by the Azure pipelines after a successful build.
  • The final task is to add an AWS code-deploy task on to the Azure-pipeline mentioning the above created AWS code deploy service details of the relevant microservices for final deployment on to the AWS Autoscaling group EC2 workload for deployments.
  • Once the YAML file with the relevant task are in place. A Pipeline can be saved and used for Continuous integration and continuous deployment purpose.
  • Any direct commit made to the AzureRepo branch linked to the Azure pipeline will auto start the pipeline by starting code pull, code build, and deploy the code to AWS infrastructure.
  • After a successful application build, an artifact will be constructed, which is then pushed to the S3 bucket, and the AWS CodeDeploy service gets triggered with the S3 artifact URL for final deployment on the AWS Autoscaling group, where Ec2 workloads will be serving the end user requests through a load balancer.

The Azure pipeline will start monitoring the AWS CodeDeploy service in each step of the deployment and provide the relevant deployment log data on AzureDevops Console.

Summary

  • AWS Toolkit on AzureDevops helps build the tasks required to carry out necessary operations across AWS and Azure.
  • It helps the development and operations teams not worry about version control and deployments being run from two different cloud providers.

Written By – Karanam Sreenivas

Cloud Computing Insights and Resources

Cloud Consulting

6 Reasons to Collaborate with a Cloud Consulting Firm in 2024

The technology landscape keeps evolving, without a break, and the shift towards cloud solutions is undeniable. Companies are increasingly embracing […]

cloud computing

10 Secrets of Optimum Utilization of Clouds 

Cloud computing has emerged as a significant trend in recent years, transforming how businesses operate and delivering a range of […]

AWS migration

An Introduction to AWS’ Migration Acceleration Program

What is AWS MAP?  The Migration Acceleration Program (MAP) stands as an exclusive offering from Amazon Web Services (AWS), available […]