Skip to content

Demo application that showcases a modern, cloud-native application

License

Notifications You must be signed in to change notification settings

edburns/PetSpotR

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PetSpotR

PetSpotR allows you to use advanced AI models to report and find lost pets. It is a sample application that uses Azure Machine Learning to train a model to detect pets in images.

It also leverages popular open-source projects such as Dapr and Keda to provide a scalable and resilient architecture.

Logo

Featured technologies

Architecture

Note: This application is a demo app which is not intended to be used in production. It is intended to demonstrate how to use Azure Machine Learning and other Azure services to build a scalable and resilient application. Use at your own risk.

PetSpotR is a microservices application that uses Azure Machine Learning to train a model to detect pets in images. It also uses Azure Blob Storage to store images and Azure Cosmos DB to store metadata, leveraging Dapr bindings and state management to abstract away the underlying infrastructure.

The frontend is a .NET Blazor application that allows users to upload images and view the results. The backend is a Python Flask application that uses Azure Machine Learning to train and score the model.

architecture

The application scales using KEDA, which allows you to scale based on the number of messages in a queue. The application uses Azure Service Bus to queue messages for the backend to process, leveraging Dapr pub/sub to abstract away the underlying infrastructure.

Azure Load Testing is used to simulate a large number of users uploading images to the application, which allows us to test the application's scalability.

Pre-requisites

Running locally

The services in this application can be run locally using the Dapr CLI. This is useful for development and testing. The ML training and scoring will run within an Azure Machine Learning workspace in your Azure subscription.

  1. Install the Dapr CLI
  2. Initialize Dapr
    dapr init
  3. Configure your Dapr images component for Windows or Mac
    1. Open ./iac/dapr/local/images.yaml
    2. Uncomment the appropriate section for your OS, and comment out the other section
  4. Deploy the required Azure resources
    az deployment group create --resource-group myrg --template-file ./iac/infra.bicep --parameters mode=dev
  5. Run the backend
    cd src/backend
    dapr run --app-id backend --app-port 6002 --components-path ../../iac/dapr/local -- python app.py
  6. Run the frontend
    cd src/frontend/PetSpotR
    dapr run --app-id frontend --app-port 5114 --components-path ../../../iac/dapr/local -- dotnet watch
  7. Navigate to http://localhost:5114

Deploying this application via CLI

  1. Ensure you have access to an Azure subscription and the Azure CLI installed
    az login
    az account set --subscription "My Subscription"
  2. Clone this repository
    git clone https://github.com/azure-samples/petspotr.git
    cd petspotr
  3. Deploy the infrastructure
    az deployment group deployment create --resource-group myrg --template-file ./iac/infra.json
  4. Deploy the configuration
    az deployment group deployment create --resource-group myrg --template-file ./iac/config.json
  5. Get AKS credentials
    az aks get-credentials --resource-group myrg --name petspotr
  6. Install Helm Charts
    helm repo add dapr https://dapr.github.io/helm-charts/
    helm repo add kedacore https://kedacore.github.io/charts
    helm repo update
    helm upgrade dapr dapr/dapr --install --version=1.10 --namespace dapr-system --create-namespace --wait
    helm upgrade keda kedacore/keda --install --version=2.9.4 --namespace keda --create-namespace --wait
  7. Log into Azure Container Registry You can get your registry name from your resource group in the Azure Portal
    az acr login --name myacr
  8. Build and push containers
    docker build -t myacr.azurecr.io/backend:latest ./src/backend
    docker build -t myacr.azurecr.io/frontend:latest ./src/frontend
    docker push myacr.azurecr.io/petspotr:latest
    docker push myacr.azurecr.io/frontend:latest
  9. Deploy the application
    az deployment group deployment create --resource-group myrg --template-file ./iac/app.json
  10. Get your frontend URL
    kubectl get svc
  11. Navigate to your frontend URL

About

Demo application that showcases a modern, cloud-native application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Bicep 30.3%
  • HTML 28.2%
  • Python 19.0%
  • CSS 10.2%
  • TypeScript 6.0%
  • C# 5.0%
  • Dockerfile 1.3%