Build a Music Recommendation System with Azure Container Apps and AI – Lab from MS Build 2024
We’re building a music recommendation service where users will be able to search and select from a set of songs, and the system will recommend similar songs to them. Below is a depiction of the architecture:
The application is composed of four different components:
- A Azure Container Apps (ACA) Jupyter Environment which teaches about and produces embeddings for our library of 11,000 songs.
- A Qdrant ACA Add-On Vector DB which stores embeddings (think of them as fingerprints) and produces our recommendations based on them.
- A ACA API app which brokers the data between the frontend UI and the vector database.
- A ACA Frontend app which provides the user-facing UI to interact with the recommendation service.
The overall intention of this application is for the user to learn about vector databases. Hence the process of deploying this application is broken up into two parts.
In part one we play the role of a data scientist or ML engineer. We will familiarize ourselves with the process of generating embeddings for our song data. This part completes when we’ve stored our embeddings in our vector database.
In part two we play the role of an application engineer and turn the stored embeddings data into a recommendation service by adding a API and frontend.
Step by Step Deployment:
az login
az provider register -n Microsoft.OperationalInsights –wait &&
az provider register -n Microsoft.ServiceLinker –wait &&
az provider register -n Microsoft.App –waitexport LOCATION=westus2
export RG=music-rec-service
export ACA_ENV=music-env
export NOTEBOOK_IMAGE=mafamafa/aca-music-recommendation-notebook
export BACKEND_IMAGE=mafamafa/aca-music-recommendation-backend
export FRONTEND_IMAGE=mafamafa/aca-music-recommendation-frontend# create the resource group
az group create -l $LOCATION –name $RGaz containerapp env create –name $ACA_ENV –resource-group $RG –location $LOCATION –enable-workload-profiles
## Create the vector db add-on
az containerapp add-on qdrant create –environment $ACA_ENV –resource-group $RG –name qdrant# add a workload profile for the large Jupyter image
az containerapp env workload-profile add –name $ACA_ENV –resource-group $RG –workload-profile-type D8 –workload-profile-name bigProfile –min-nodes 1 –max-nodes 1az containerapp create –name music-jupyter –resource-group $RG –environment $ACA_ENV –image $NOTEBOOK_IMAGE –cpu 4 –memory 16.0Gi –workload-profile-name bigProfile –min-replicas 1 –max-replicas 1 –target-port 8888 –ingress external –bind qdrant
az containerapp logs show -g $RG -n music-jupyter | grep token
####Open in Portal music-jupyter url and put Token
####Start.ipnyb
####Import.ipnyb
# launch the backend application
az containerapp create –name music-backend –resource-group $RG –environment $ACA_ENV –image $BACKEND_IMAGE –cpu 4 –memory 8.0Gi –workload-profile-name bigProfile –min-replicas 1 –max-replicas 1 –target-port 8000 –ingress external –bind qdrant####http://<YOUR_ACA_ASSIGNED_DOMAIN>/songs
az containerapp create –name music-frontend –resource-group $RG –environment $ACA_ENV –image $FRONTEND_IMAGE –cpu 2 –memory 4.0Gi –min-replicas 1 –max-replicas 1 –ingress external –target-port 8080 –env-vars UI_BACKEND=https://music-backend.<YOUR_UNIQUE_ID>.westus2.azurecontainerapps.io
GPU:
# create the environment first
az containerapp env create –name $ACA_ENV –resource-group $RG –location $LOCATION –enable-workload-profiles –enable-dedicated-gpuaz containerapp create –name music-jupyter –resource-group $RG –environment $ACA_ENV –image mafamafa/aca-music-recommendation-notebook:gpu –cpu 24 –memory 48.0Gi –workload-profile-name gpu –min-replicas 1 –max-replicas 1 –target-port 8888 –ingress external –bind qdrant