Help Deploying a Fine-Tuned LLaMA 3.2 Model with Streamlit on Azure

Shraddha Bangad 0 Reputation points
2025-01-15T18:40:08.61+00:00

Hey everyone,

I need some help deploying a machine learning application on Azure. Here's what I've done so far:

  • I fine-tuned a LLaMA 3.2 model for a binary classification task on my local machine.
  • The fine-tuned model is saved locally.
  • I'm using Streamlit to create the frontend and run the app locally.

Now, I want to deploy this app on Azure, but I’m completely new to Azure and unsure how to proceed.

Specifically, I’m looking for guidance on:

  1. Best Azure service to deploy this kind of app (e.g., Azure App Service, Azure Container Instances, Azure ML, or something else).
  2. How to handle model storage—should I upload the model to Blob Storage or package it with the app?
  3. Steps to deploy a Streamlit app integrated with the model.
  4. Any tips on managing dependencies and environment setup on Azure.
  5. Considerations for scalability or cost optimization.

Any tutorials, documentation, or advice you can share would be greatly appreciated!

Thanks in advance!

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,073 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Amira Bedhiafi 27,596 Reputation points
    2025-01-15T22:15:05.1966667+00:00

    Which Azure service is best for deploying this kind of app?

    Azure offers several services for deploying your app, depending on your requirements. If you need a simple and straightforward deployment, Azure App Service is a great choice because it natively supports Python web apps and requires minimal configuration. For containerized deployment, Azure Container Instances (ACI) is ideal for lightweight apps, while Azure Kubernetes Service (AKS) is better suited for large-scale or production-grade applications. Alternatively, Azure Machine Learning (Azure ML) is recommended if your deployment needs robust ML workflows, including managed endpoints for model inferencing.

    How should I handle model storage? If your fine-tuned model is large, storing it in Azure Blob Storage is an efficient option. This approach separates your app from the model and makes it easy to update or access the model independently. Use Azure SDKs to load the model dynamically within your Streamlit app. For smaller models or faster prototyping, you can package the model directly with your application code.

    What are the steps to deploy a Streamlit app integrated with the model? First, verify if all your dependencies are defined in a requirements.txt or conda.yml file.

    For Azure App Service, you can deploy your app by uploading the application folder through the Azure Portal, CLI, or GitHub Actions. If you plan to use containers, create a Dockerfile that includes your Streamlit app, install necessary libraries, and expose the required ports. Push the Docker image to Azure Container Registry and deploy it to ACI or AKS. For Azure ML, register your model, create an environment, and deploy an inferencing endpoint, which your Streamlit app can call via API.

    How should I manage dependencies and environment setup on Azure?

    Dependencies must be listed in your requirements.txt file or included in a Dockerfile. If using App Service, specify the Python runtime during configuration. For containerized deployments, ensure your Dockerfile includes system dependencies, Python libraries, and any necessary GPU configurations. In Azure ML, create a custom environment using a YAML file to specify dependencies.

    What are the considerations for scalability and cost optimization?

    For scalability, you need to use Azure App Service auto-scaling features to adjust resources based on demand. If deploying to AKS, use cluster autoscaling to scale pods dynamically. For cost optimization, start with low-tier VMs during development and switch to production tiers as needed. Additionally, consider spot VMs or reserved instances for reduced pricing, and monitor costs using Azure Cost Management tools.

    Links to help you :

    Deploy Python Apps on Azure App Service

    Deploy Streamlit on Azure (Medium)

    Deploy Models on Azure ML

    Deploy Containers on ACI

    Scale Your App on Azure

    0 comments No comments

  2. Pavankumar Purilla 2,595 Reputation points Microsoft Vendor
    2025-01-16T01:27:23.6933333+00:00

    Hi Shraddha Bangad,

    Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!

    For deploying a machine learning application, you have several options on Azure:

    Azure App Service: Ideal for deploying web apps, including Streamlit applications. It supports continuous deployment and scaling.

    Azure Container Instances (ACI): Suitable for running containerized applications without managing the underlying infrastructure.

    Azure Kubernetes Service (AKS): Best for large-scale deployments requiring orchestration and scaling of containers.

    Azure Machine Learning (Azure ML): Provides a managed platform for training, deploying, and managing machine learning models. It supports various deployment scenarios, including real-time and batch inference

    Model storage:

    Azure Blob Storage: Upload your fine-tuned model to Blob Storage. This is a cost-effective and scalable solution for storing large files.

    Steps to Deploy a Streamlit App Integrated with the Model:

    Prepare Your Streamlit App:

    Ensure your app has a requirements.txt file listing all dependencies.

    Create a Dockerfile if you plan to use containers.

    Create an Azure App Service:

    Log in to the Azure Portal and create a new Web App.

    Choose Python as the runtime stack and configure deployment settings.

    Deploy Your App:

    Use VSCode or Azure CLI to deploy your app. You can also set up continuous deployment from a GitHub repository.

    If using Docker, push your Docker image to Azure Container Registry (ACR) and deploy it using Azure App Service or AKS.

    Configure the Startup Command:

    For Streamlit, you might need to add a startup command to run the app on the specified port.

    Managing Dependencies and Environment Setup:

    Azure Machine Learning Environments: Use Azure ML environments to manage and reproduce your project's software dependencies. You can create custom environments or use curated ones provided by Azure.

    Docker: If using Docker, specify all dependencies in the Dockerfile and use Docker Compose for local testing before deploying to Azure.

    Scalability and Cost Optimization

    Autoscaling: Configure autoscaling for your compute resources to handle varying workloads efficiently. Azure ML and AKS support autoscaling.

    Cost Management: Use low-priority VMs, reserved instances, and set quotas to manage and optimize costs. Azure provides tools to monitor and control spending.

    For more information Deploy Python Apps on Azure App Service.

    Deploy Streamlit on Azure Web App.

    Azure Blob Storage documentation.

    Hope this helps. Do let us know if you have any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.