Git Product home page Git Product logo

deploy-webserver-azure's Introduction

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

Introduction

Using this repo, you can deploy a scalable webserver in Azure using Infrastructure as a Code (IaC) techniques. The code uses HashiCorp's Terraform to deploy a webserver in Azure. The virtual machine template is created using Packer while the Microsoft's Azure CLI is used to deploy the virtual machine like a script. Let's start!

Getting Started

  1. Clone this repository

  2. Create your infrastructure as code

  3. Update this README to reflect how someone would use your code.

Dependencies

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

Instructions

After fulfilling the dependencies, you can follow the steps below to deploy a webserver in Azure.

  1. Clone this repository using git clone
  2. Open the Azure Cli and login to your Azure account using az login
  3. Create a resource group using:
az group create --name udacity-project1 --location francecentral --tags "udacity=project1"
  1. Create and deploy the custom policy using:
 az policy definition create --name "tagging-policy" --display-name "Tagging-policy" --description "Enforcing all resource to have tags" --rules "policy.json" --mode All

 az policy assignment create --policy tagging-policy --name "tagging-policy"  --display-name "Tagging policy" --description "Policy to enforce tagging on all resources in the subscription"
  1. Verify the deployment using az policy assignment list. The output should be something like this: PolicyAssignment

  2. Packer needs some enviornment variables which you can obtain by running the following command:

  az ad sp create-for-rbac --role Contributor --scopes /subscriptions/<subscription_id> --query "{ client_id: appId, client_secret: password}"  

you can use these values inside the packer.json file's variables section or you can import them into your .env file using

    export ARM_CLIENT_ID=<client_id>
    export ARM_CLIENT_SECRET=<client_secret>
    export ARM_SUBSCRIPTION_ID=<subscription_id>
  1. Now built the packer template using packer build .\server.json.This will take sometime and you will see the image inside the resource group. You can use the az image list command to verify the deployment. Alrernatively you could also see on the Azure portal which will look something like this: Packer Image on the portal

  2. Now, since the stage is ready, it's time to deploy the webserver. Use the following command to deploy the webserver:

terraform init
terraform import azurerm_resource_group.main /subscriptions/<subscription_id>/resourceGroups/udacity-project1
terraform plan -out solution.plan
terraform apply solution.plan
  1. To verify the deployment, use the following command:
terraform show
  1. To delete the deployment, use the following command:
terraform destroy

It will ask for a confirmation before deleting the deployment in a following manner:

Output

The output of the deployment will look something like this: Azure Portal

deploy-webserver-azure's People

Contributors

shahzebanwar 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.