Giter Site home page Giter Site logo

john0isaac / azure-flask-mysql-flexible-appservice Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 5.08 MB

Web app using Python Flask backend, set up for deployment to Azure App Service with Azure MySQL Flexible Server.

License: MIT License

Bicep 32.15% Shell 0.08% Python 7.28% Mako 0.14% CSS 52.75% SCSS 5.28% HTML 2.33%

azure-flask-mysql-flexible-appservice's Introduction

page_type languages products urlFragment name description
sample
azdeveloper
python
bicep
html
css
scss
azure
azure-app-service
azure-mysql
azure-flask-mysql-flexible-appservice
Deploy Flask Application with MySQL on Azure App Service (Python)
This project deploys a web application for a space travel agency using Flask with Python, and is set up for easy deployment with the Azure Developer CLI.

Deploy Flask Application with MySQL via Azure App Service

This project deploys a web application for a space travel agency using Flask. The application can be deployed to Azure with Azure App Service using the Azure Developer CLI.

Opening the project

This project has Dev Container support, so it will be setup automatically if you open it in GitHub Codespaces or in local VS Code with the Dev Containers extension.

If you're not using one of those options for opening the project, then you'll need to:

  1. Start up a local MySQL server, create a database for the app, and set the following environment variables according to your database configuration.

    export MYSQL_HOST=127.0.0.1
    export MYSQL_PORT=3306
    export MYSQL_DATABASE=<YOUR DATABASE>
    export MYSQL_USER=<YOUR USERNAME>
    export MYSQL_PASS=<YOUR PASSWORD>
  2. Create a Python virtual environment and activate it.

  3. Install production requirements:

    python3 -m pip install -r src/requirements.txt
  4. Install the app as an editable package:

    python3 -m pip install -e src
  5. Apply database migrations and seed initial data:

    python3 -m flask --app src.flaskapp db upgrade --directory src/flaskapp/migrations
    python3 -m flask --app src.flaskapp seed --filename src/seed_data.json

Running locally

If you're running the app inside VS Code or GitHub Codespaces, you can use the "Run and Debug" button to start the app.

python3 -m flask --app src.flaskapp run --debug --reload --port=5000

Running tests

  1. Install the development requirements:

    python3 -m pip install -r requirements-dev.txt
    python3 -m playwright install chromium --with-deps
  2. Run the tests:

    python3 -m pytest

Deployment

This repo is set up for deployment on Azure via Azure App Service.

Steps for deployment:

  1. Sign up for a free Azure account and create an Azure Subscription.

  2. Install the Azure Developer CLI. (If you open this repository in Codespaces or with the VS Code Dev Containers extension, that part will be done for you.)

  3. Login to Azure:

    azd auth login
  4. Provision and deploy all the resources:

    azd up

    It will prompt you to provide an azd environment name (like "myapp"), select a subscription from your Azure account, and select a location (like "eastus"). Then it will provision the resources in your account and deploy the latest code. If you get an error with deployment, changing the location can help, as there may be availability constraints for some of the resources.

  5. When azd has finished deploying, you'll see an endpoint URI in the command output. Visit that URI, and you should see the front page of the app! ๐ŸŽ‰

  6. When you've made any changes to the app code, you can just run:

    azd deploy

CI/CD pipeline

This project includes a GitHub workflow for deploying the resources to Azure on every push to main. That workflow requires several Azure-related authentication secrets to be stored as GitHub action secrets. To set that up, run:

azd pipeline config

azure-flask-mysql-flexible-appservice's People

Watchers

 avatar  avatar

Forkers

engrmahabub afs26

azure-flask-mysql-flexible-appservice's Issues

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.