Giter Site home page Giter Site logo

mabubakarriaz / blogi-backend Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 39 KB

A dockized sample ASP.net core web API with CI/CD on Azure Pipeline

License: Apache License 2.0

C# 77.78% Dockerfile 22.22%
api asp-net-core azure-pipeline docker restful-api ci-cd sample

blogi-backend's Introduction

Objective

Please perform the following assignment project on Azure by using ACloud Guru Sandbox, and record screen videos after completion of every activity.

  • Pick any open source .net project or.net core from the internet
  • Front End sample on angular
  • Choose a sample db SQL based
  • Create a docker file for these
  • Setup Azure DevOps CI/CD pipelines
  • Create an Azure Architecture diagram, and choose wisely it is totally up to you how you want to deploy and host
  • DB should be in a private subnet and cant be accessible over the internet
  • Configure SSL on the domain, you can use a custom subdomain from tkxel-team.com
  • Setup DNS on CloudFlare
  • You can choose any web server

Instructions

Service Connections

  • Project Settings > Service Connections > Create Service Connection
  • Connections Required
    • Github
      • mabubakarriaz
    • Docker Hub
      • docker-registry
    • SSH a VM
      • ssh-vm

Web VM Setup

  • Create linux vm
  • Select web subnet
  • Install docker by following below Docker Setup.
  • Install sql client by following below SQL CMD setup.

Database

  • create sql server instance
  • create sql database
  • Create vnet service end point with microsoft.sql
  • create private end point for sql
  • create private DNS entry

Build Agent Setup

  • Create Personal Access Token (PAT) from Azure DevOps

    • User Settings > Personal Access Tokens > New Token > Scope > 'full access'
  • Create a VM build agent

    • Project Settings > Agent Pools > Default > New Agent > Linux
  • Download agent

    wget https://vstsagentpackage.azureedge.net/agent/3.218.0/vsts-agent-linux-x64-3.218.0.tar.gz
  • Create the agent ( the file name may be updated see online instructions)

    mkdir myagent && cd myagent
    tar zxvf ~/vsts-agent-linux-x64-3.218.0.tar.gz
  • Configue agent

    ./config.sh
  • Run the agent interactively (TODO: write steps to run agent non-interactively)

    ./run.sh
  • Install docker by following below Docker Setup.

  • To speed up pull these images

    docker pull mcr.microsoft.com/dotnet/aspnet:7.0
    docker pull mcr.microsoft.com/dotnet/sdk:7.0
  • run the interactive agent runner ./run.sh

Docker Setup

Script to setup docker on linux vm by using https://docs.docker.com/engine/install/ubuntu/

  • ssh into vm

    ssh -i vm-key.pem [email protected]
  • Uninstall old versions

    sudo apt-get remove docker docker-engine docker.io containerd runc
  • Update the apt package index and install packages to allow apt to use a repository over HTTPS:

    sudo apt-get update
    sudo apt-get install \
        ca-certificates \
        curl \
        gnupg
  • Add Docker’s official GPG key:

    sudo mkdir -m 0755 -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  • Use the following command to set up the repository:

    echo \
      "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  • Grant access to gpg

    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    sudo apt-get update
  • Install Docker Engine, containerd, and Docker Compose.

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  • Grant running use access

    sudo usermod -aG docker $(whoami)
    sudo service docker restart
  • verify by runing container

    sudo docker run hello-world

SQL CMD setup

Script to setup sql cmd utilities on vm using link https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?tabs=ubuntu-install%2Credhat-offline&view=sql-server-ver16#ubuntu

  • ssh into vm

    ssh -i vm-key.pem [email protected]
  • Import the public repository GPG keys.

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  • Register the Microsoft Ubuntu repository.

    curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
  • Update the sources list and run the installation command with the unixODBC developer package.

    sudo apt-get update
    sudo apt-get install mssql-tools unixodbc-dev
  • To make sqlcmd/bcp accessible from the bash shell for login sessions

    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
  • To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions,

    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
    source ~/.bashrc
  • connection string from vm

    sqlcmd -S tcp:blogisqlserver003223.database.windows.net,1433 -d AdventureWorksLT -U azureuser -P myPassword

Important commands

blogi-backend's People

Contributors

mabubakarriaz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.