GithubHelp home page GithubHelp logo

azure-devops-deploy-web-server's Introduction

Azure Infrastructure Operations Project: Deploying a scalable IaaS web server in Azure

alt text

Introduction

Infrastructure as code is one of the five practices that we consider the heart of DevOps. Infrastructure as code provides a significant benefit in terms of creating, deploying, upgrading, and deleting infrastructure. Infrastructure as code make the deployment procedure as simple as pressing a button.

Packer a server templating software written in JSON, will be used to create virtual machine images containing our application for repeatable deployments. Terraform is a provisioning tool that creates infrastructure according to a configuration file that you create. This file can be saved and reused which enables you to safely and predictably create, change, and improve infrastructure.

For this project, you will write a Packer template and a Terraform template to deploy a customizable, scalable web server in Azure.

Getting Started

  1. Clone this repository

  2. Create your infrastructure as code

  3. Create your tagging-policy in Azure

  4. Create your resource group in Azure

Dependencies

  1. Create an Azure Account
  2. Install latest version Azure command line interface
  3. Install latest version Packer
  4. Install latest version Terraform

Instructions

Once you've gathered your dependencies, we'll need the following steps to deploy the scalable web server on Azure:

  1. Deploy the packer image
  2. Deploy the infrastructure with Terraform template

๐Ÿ”ด Deploy the Packer Image ๐Ÿ”ด

Using packer we will deploy virtual machines images. Before that set the environment variable as following

::pencil:: Config Environment Variables ::pencil::

Go to the setEnv.sh script and set the environment variables like below.

export ARM_CLIENT_ID=d12050fc-42aa-4e02-84ed-3b7663b17b6f
export ARM_CLIENT_SECRET=bbR8Q~vWk2Qwg4yrsov2piwWXwaJSwEnlQ~yWc5O
export ARM_SUBSCRIPTION_ID=13e7b74b-ca4b-405f-9015-8032555cec7c
export ARM_TENANT_ID=f958e84a-92b8-439f-a62d-4f45996b6d07

Then run the following command

chmod a+x setEnv.sh
sources setEnv.sh

After you have set the environment variables, use 'printenv ' to ensure that they are correctly configured.

printenv | grep "ARM_CLIENT_ID"

โ˜‘๏ธ Get Client ID

  • Login into your azure account
  • Search and click "Azure Active Directory"
  • Click "App registrations" under the Manage tab
  • Click the application that you own
  • Copy the client ID

โ˜‘๏ธ Get Client Secret

  • Login into your azure account
  • Search and click "Azure Active Directory"
  • Click "App registrations" under the Manage tab
  • Click the application that you own
  • Click the "Certificates & Secrets" under the Manage tab
  • Create a client secret as you need.

โ˜‘๏ธ Get Subscription ID

  • Login into your azure account
  • Search and click "Subscriptions"
  • Choose the subscriptions that are required.
  • Click on the overview
  • Copy the Subscription Id

Please check the link for more clear visualization a link

๐Ÿ”ด Deploy the Packer Image ๐Ÿ”ด

Run the following command to deploy the packer image.

packer build server.json

This can take quite a while so feel free to get your self a drink โ˜•

packer output Then we can access (i.e. list or delete) this image using the CLI: To delete image at the end use the following (skip it for our case )

az image list
az image delete -g packer-rg -n myPackerImage

๐Ÿ”ด Deploy the infrastructure with Terraform template ๐Ÿ”ด

To use variables for your main.tf, you can specify your variables like below in your variables.tf file.

variable "prefix" {
  description = "The prefix which should be used for all resources in this example"
  default = "udacity"
}

And in your main.tf, you can call the variables like

var.prefix

Import resource group

We've previously established the resources group for our PackerImage, hence we can't deploy the same resource group. We must import the existing resource group before it can determine which resource group to install.

cd /terraform-provider-azurerm/web-server
terraform init
terraform import azurerm_resource_group.main /subscriptions/{subsriptionId}/resourceGroups/{resourceGroupName}
az login -u your-user-name -p your-password

To deploy our configuration, run the following commands:

cd /terraform-provider-azurerm/web-server

terraform plan -out solution.plan

terraform Plan

cd /terraform-provider-azurerm/web-server

terraform apply

Output

If you were successful in deploying the resources, it would look like this:

tarraform Apply

You may also check the Azure site to see if these resources have been delivered. The end outcome will be as follows.

Azrue-portal-output1 Azrue-portal-output2

In the terminal, type terraform show to check the resources

cd /terraform-provider-azurerm/web-server
terraform show

After the deployment, remember to destroy the resources.

cd /terraform-provider-azurerm/web-server
terraform destroy

Please see the report for more

azure-devops-deploy-web-server's People

Contributors

dawitanelay avatar

Stargazers

 avatar

Watchers

 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.