GithubHelp home page GithubHelp logo

minhdua / nd081-c3-migrating-non-native-cloud-applications-project-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from udacity/nd081-c3-migrating-non-native-cloud-applications-project-starter

0.0 0.0 0.0 4.88 MB

License: Other

JavaScript 13.71% Python 9.60% CSS 58.39% HTML 18.30%

nd081-c3-migrating-non-native-cloud-applications-project-starter's Introduction

TechConf Registration Website

Project Overview

The TechConf website allows attendees to register for an upcoming conference. Administrators can also view the list of attendees and notify all attendees via a personalized email message.

The application is currently working but the following pain points have triggered the need for migration to Azure:

  • The web application is not scalable to handle user load at peak
  • When the admin sends out notifications, it's currently taking a long time because it's looping through all attendees, resulting in some HTTP timeout exceptions
  • The current architecture is not cost-effective

In this project, you are tasked to do the following:

  • Migrate and deploy the pre-existing web app to an Azure App Service
  • Migrate a PostgreSQL database backup to an Azure Postgres database instance
  • Refactor the notification logic to an Azure Function via a service bus queue message

Dependencies

You will need to install the following locally:

Project Instructions

Part 1: Create Azure Resources and Deploy Web App

  1. Create a Resource group
  2. Create an Azure Postgres Database single server
    • Add a new database techconfdb
    • Allow all IPs to connect to database server
    • Restore the database with the backup located in the data folder
  3. Create a Service Bus resource with a notificationqueue that will be used to communicate between the web and the function
    • Open the web folder and update the following in the config.py file
      • POSTGRES_URL
      • POSTGRES_USER
      • POSTGRES_PW
      • POSTGRES_DB
      • SERVICE_BUS_CONNECTION_STRING
  4. Create App Service plan
  5. Create a storage account
  6. Deploy the web app

Part 2: Create and Publish Azure Function

  1. Create an Azure Function in the function folder that is triggered by the service bus queue created in Part 1.

    Note: Skeleton code has been provided in the README file located in the function folder. You will need to copy/paste this code into the __init.py__ file in the function folder.

    • The Azure Function should do the following:
      • Process the message which is the notification_id
      • Query the database using psycopg2 library for the given notification to retrieve the subject and message
      • Query the database to retrieve a list of attendees (email and first name)
      • Loop through each attendee and send a personalized subject message
      • After the notification, update the notification status with the total number of attendees notified
  2. Publish the Azure Function

Part 3: Refactor routes.py

  1. Refactor the post logic in web/app/routes.py -> notification() using servicebus queue_client:
    • The notification method on POST should save the notification object and queue the notification id for the function to pick it up
  2. Re-deploy the web app to publish changes

Monthly Cost Analysis

Complete a month cost analysis of each Azure resource to give an estimate total cost using the table below:

Azure Resource Service Tier Monthly Cost
Azure Postgres Database Basic - Single Server $65.08
Azure Service Bus Basic Service Plan - B1 $13.14
App Service Basic $0.05
Azure Functions Consumption Tier $0
Storage Accounts Storage (general purpose v1) $0.018

Architecture Explanation

  1. Azure Postgres Database:

    • Service Tier: Basic - Single Server
    • Monthly Cost: $65.08
    • Explanation:
      • The Basic tier was chosen for cost effectiveness while meeting database requirements.
      • The Single Server option suits small applications, providing a standalone PostgreSQL server.
      • This tier provides a balance of performance and cost for your database needs.
  2. App Service:

    • Service Tier: Basic
    • Monthly Cost: $0.05
    • Explanation:
      • The Basic tier was chosen to keep costs low while meeting the needs to host a Flask based web application.
      • This tier provides enough resources for small to medium applications.
      • App Service provides easy and scalable deployments on demand.
  3. Azure Functions:

    • Service Tier: Consumption Tier
    • Monthly Cost: (Not specified in the table)
    • Explanation:
      • The Consumption tier was chosen for Azure Functions to take advantage of a serverless architecture.
      • This tier incurs costs based on actual usage, making it cost effective for uneven workloads.
      • Azure Functions handles background processing tasks, like notification jobs, in an event-driven way.

Additional Considerations:

  • Azure Service Bus:

    • Service Tier: Basic Service Plan - B1
    • Monthly Cost: $13.14
    • Explanation:
      • The Basic Service Plan provides enough capabilities for message queuing.
      • B1 was chosen for cost effectiveness while meeting the application's needs.
      • Azure Service Bus supports asynchronous communication between the web application and Azure Functions.
  • Storage Accounts:

    • Service Tier: Storage (general purpose v1)
    • Monthly Cost: (Not specified in the table)
    • Explanation:
      • A Storage account can be used to store static assets, logs, or other data.
      • General-purpose v1 is a standard storage tier suitable for many storage needs.
      • Costs depend on the amount of data stored and operations performed.

This architecture enables efficient handling of user interactions, background processing, and communication between components, ensuring a cost-effective and scalable solution for the application.

nd081-c3-migrating-non-native-cloud-applications-project-starter's People

Contributors

saitamacoder196 avatar sudkul avatar chrvasq avatar petespangler avatar sripriyamohan 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.