{"id":16507890,"url":"https://github.com/noahgift/flask-ml-azure-serverless","last_synced_at":"2025-07-19T13:13:31.074Z","repository":{"id":141810274,"uuid":"285598569","full_name":"noahgift/flask-ml-azure-serverless","owner":"noahgift","description":"Deploy Flask Machine Learning Application on Azure App Services","archived":false,"fork":false,"pushed_at":"2025-01-10T22:55:55.000Z","size":251,"stargazers_count":109,"open_issues_count":6,"forks_count":213,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T00:07:21.070Z","etag":null,"topics":["northwestern","northwestern-434","oreilly-books","udacity"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noahgift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-06T14:54:35.000Z","updated_at":"2025-04-02T19:40:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"40efab42-40ee-40e9-a2c9-abb1cdae9276","html_url":"https://github.com/noahgift/flask-ml-azure-serverless","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahgift%2Fflask-ml-azure-serverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahgift%2Fflask-ml-azure-serverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahgift%2Fflask-ml-azure-serverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahgift%2Fflask-ml-azure-serverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noahgift","download_url":"https://codeload.github.com/noahgift/flask-ml-azure-serverless/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625498,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["northwestern","northwestern-434","oreilly-books","udacity"],"created_at":"2024-10-11T15:31:34.694Z","updated_at":"2025-04-12T19:48:14.184Z","avatar_url":"https://github.com/noahgift.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 🎓 Pragmatic AI Labs | Join 1M+ ML Engineers\n\n### 🔥 Hot Course Offers:\n* 🤖 [Master GenAI Engineering](https://ds500.paiml.com/learn/course/0bbb5/) - Build Production AI Systems\n* 🦀 [Learn Professional Rust](https://ds500.paiml.com/learn/course/g6u1k/) - Industry-Grade Development\n* 📊 [AWS AI \u0026 Analytics](https://ds500.paiml.com/learn/course/31si1/) - Scale Your ML in Cloud\n* ⚡ [Production GenAI on AWS](https://ds500.paiml.com/learn/course/ehks1/) - Deploy at Enterprise Scale\n* 🛠️ [Rust DevOps Mastery](https://ds500.paiml.com/learn/course/ex8eu/) - Automate Everything\n\n### 🚀 Level Up Your Career:\n* 💼 [Production ML Program](https://paiml.com) - Complete MLOps \u0026 Cloud Mastery\n* 🎯 [Start Learning Now](https://ds500.paiml.com) - Fast-Track Your ML Career\n* 🏢 Trusted by Fortune 500 Teams\n\nLearn end-to-end ML engineering from industry veterans at [PAIML.COM](https://paiml.com)\n\n# flask-ml-azure-serverless\nDeploy Flask Machine Learning Application on Azure App Services\n\n![continuous-delivery](https://user-images.githubusercontent.com/58792/85061538-f7352780-b174-11ea-8001-b0561c5bad73.jpg)\n\n## If you run into problems\n\n* Build the container using Docker commands in the `Makefile`\n* Rebuild the model using a later version of sklearn and update requirements.txt with your version of sklearn\n\n\n## To run it locally follow these steps (on Python 3.8, there are issues on later version of Python)\n\n1.  Create virtual environment and source\n\n```bash\npython3 -m venv ~/.flask-ml-azure\nsource ~/.flask-ml-azure/bin/activate\n```\n\n2.  Run `make install`\n\n3.  Run `python app.py`\n\n4.  In a separate shell run: `./make_prediction.sh`\n\n## To run it in Azure Pipelines\n\n1.  Refer to [Azure Official Documentation guide here throughout](https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python-webapp?view=azure-devops)\n\n2. Launch Azure Shell  \n\n![1-launch-azure-shell](https://user-images.githubusercontent.com/58792/89555246-cc169e00-d7dd-11ea-8164-88caa1b8beba.png)\n\n3.  Create Github Repo with Azure Pipelines Enabled (Could be a fork of this repo)\n\n![2-create-Github-Repo](https://user-images.githubusercontent.com/58792/89555912-a3db6f00-d7de-11ea-9d2f-5ac030b43ec9.png)\n\n4. Clone the repo into Azure Cloud Shell\n\n*Note:  You make need to follow this YouTube video guide on how to [setup SSH keys and configure cloudshell environment](https://www.youtube.com/watch?v=3vtBAfPjQus)*\n\n5.  Create virtual environment and source\n\n```bash\npython3 -m venv ~/.flask-ml-azure\nsource ~/.flask-ml-azure/bin/activate\n```\n\n2.  Run `make install`\n\n3.  Create an app service and initially deploy your app in Cloud Shell\n\n`az webapp up -n \u003cyour-appservice\u003e`\n\n![3-flask-ml-service](https://user-images.githubusercontent.com/58792/89557009-2e709e00-d7e0-11ea-9b31-9090c8067a10.png)\n\n4. Verify deployed application works by browsing to deployed url: `https://\u003cyour-appservice\u003e.azurewebsites.net/`\n\nYou will see this output:\n\n![4-deployed-app](https://user-images.githubusercontent.com/58792/89557343-a8088c00-d7e0-11ea-891c-4d88333b8097.png)\n\n5.  Verify Machine Learning predictions work\n\nChange the line in `make_predict_azure_app.sh` to match the deployed prediction\n`-X POST https://\u003cyourappname\u003e.azurewebsites.net:$PORT/predict `\n\n![5-successful-prediction](https://user-images.githubusercontent.com/58792/89557573-02a1e800-d7e1-11ea-8318-1c628e13dae7.png)\n\n6. [Create an Azure DevOps project and connect to Azure, (as official documentation describes)](https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python-webapp?view=azure-devops)\n\n![6-devops](https://user-images.githubusercontent.com/58792/89558313-097d2a80-d7e2-11ea-8b65-df052b300331.png)\n\n7.  Connect to Azure Resource Manager\n\n![7-service-connection](https://user-images.githubusercontent.com/58792/89558869-d0918580-d7e2-11ea-8ffe-52cfaf95fe16.png)\n\n8.  Configure connection to previously deployed resource group\n\n![8-azure-pipelines-setup](https://user-images.githubusercontent.com/58792/89560149-988b4200-d7e4-11ea-9e25-3554ac2bd8fd.png)\n\n9.  Create new Python Pipeline with Github Integration\n\n![9-newpipeline](https://user-images.githubusercontent.com/58792/89560429-f750bb80-d7e4-11ea-9f85-241d65d25c55.png)\n\n![10-github-integration](https://user-images.githubusercontent.com/58792/89560627-5282ae00-d7e5-11ea-8b0b-bdecfff0e4d3.png)\n\n\nThis process will create a YAML file that looks roughly like the YAML output shown below.  Refer to the [official Azure Pipeline YAML documentation for more information about it](https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python-webapp?view=azure-devops#yaml-pipeline-explained).\n\n```\n# Python to Linux Web App on Azure\n# Build your Python project and deploy it to Azure as a Linux Web App.\n# Change python version to one thats appropriate for your application.\n# https://docs.microsoft.com/azure/devops/pipelines/languages/python\n\ntrigger:\n- master\n\nvariables:\n  # Azure Resource Manager connection created during pipeline creation\n  azureServiceConnectionId: '\u003cyouridhere\u003e'\n  \n  # Web app name\n  webAppName: 'flask-ml-service'\n\n  # Agent VM image name\n  vmImageName: 'ubuntu-latest'\n\n  # Environment name\n  environmentName: 'flask-ml-service'\n\n  # Project root folder. Point to the folder containing manage.py file.\n  projectRoot: $(System.DefaultWorkingDirectory)\n  \n  # Python version: 3.7\n  pythonVersion: '3.7'\n\nstages:\n- stage: Build\n  displayName: Build stage\n  jobs:\n  - job: BuildJob\n    pool:\n      vmImage: $(vmImageName)\n    steps:\n    - task: UsePythonVersion@0\n      inputs:\n        versionSpec: '$(pythonVersion)'\n      displayName: 'Use Python $(pythonVersion)'\n    \n    - script: |\n        python -m venv antenv\n        source antenv/bin/activate\n        python -m pip install --upgrade pip\n        pip install setup\n        pip install -r requirements.txt\n      workingDirectory: $(projectRoot)\n      displayName: \"Install requirements\"\n\n    - task: ArchiveFiles@2\n      displayName: 'Archive files'\n      inputs:\n        rootFolderOrFile: '$(projectRoot)'\n        includeRootFolder: false\n        archiveType: zip\n        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip\n        replaceExistingArchive: true\n\n    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip\n      displayName: 'Upload package'\n      artifact: drop\n\n- stage: Deploy\n  displayName: 'Deploy Web App'\n  dependsOn: Build\n  condition: succeeded()\n  jobs:\n  - deployment: DeploymentJob\n    pool:\n      vmImage: $(vmImageName)\n    environment: $(environmentName)\n    strategy:\n      runOnce:\n        deploy:\n          steps:\n          \n          - task: UsePythonVersion@0\n            inputs:\n              versionSpec: '$(pythonVersion)'\n            displayName: 'Use Python version'\n\n          - task: AzureWebApp@1\n            displayName: 'Deploy Azure Web App : flask-ml-service'\n            inputs:\n              azureSubscription: $(azureServiceConnectionId)\n              appName: $(webAppName)\n              package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip\n  ```\n10.  Verify Continuous Delivery of Azure Pipelines by changing `app.py`\n\nYou can watch this [YouTube Walkthrough of this process](https://www.youtube.com/watch?v=3KF9DltYvZU)\n\n11.  Add a lint step (this gates your code against syntax failure)\n\n```\n    - script: |\n        python -m venv antenv\n        source antenv/bin/activate\n        make install\n        make lint\n      workingDirectory: $(projectRoot)\n      displayName: 'Run lint tests'\n```\n\nYou can watch this [YouTube Walkthrough of this process](https://www.youtube.com/watch?v=TItOatTfAOc)\n\n\n### [Cloud Computing for Data Analysis Book](https://leanpub.com/cloud4data)\nThis book is being written \"just in time\", with a weekly release schedule.\n\n![cloud4data books](https://d2sofvawe08yqg.cloudfront.net/cloud4data/hero2x?1578933644)\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahgift%2Fflask-ml-azure-serverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoahgift%2Fflask-ml-azure-serverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahgift%2Fflask-ml-azure-serverless/lists"}