AI/ML, Automation, Google Cloud (GCP)

< 1 min

Automating Vertex AI Batch Prediction Jobs with Cloud Run and Google Cloud Storage

Voiced by Amazon Polly

Introduction

Organizations often need to process large volumes of data for machine learning inference, such as document classification, sentiment analysis, recommendation generation, content moderation, or generative AI workloads. Running predictions one request at a time can be inefficient and costly when dealing with thousands or millions of records.

Google Cloud’s Vertex AI Batch Prediction enables organizations to submit large datasets for asynchronous processing without managing infrastructure. When combined with Cloud Storage and Cloud Run, it becomes possible to build a fully automated, serverless inference pipeline that scales with demand.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

What is Vertex AI Batch Prediction?

Vertex AI Batch Prediction allows users to submit datasets stored in Cloud Storage or BigQuery and receive prediction results asynchronously.

Unlike online prediction endpoints, batch prediction:

  • Does not require a continuously running endpoint
  • Is optimized for large-scale processing
  • Supports asynchronous execution
  • Reduces operational overhead
  • Is well-suited for scheduled and event-driven workloads

Common use cases include:

  • Document classification
  • Customer feedback analysis
  • Product categorization
  • Recommendation generation
  • Forecasting
  • Generative AI batch inference
  • Data enrichment pipelines

High-Level Architecture

Workflow

  1. A JSONL file is uploaded to a GCS bucket.
  2. An Eventarc trigger invokes a Cloud Run service.
  3. Cloud Run extracts the file path from the event.
  4. Cloud Run calls the Vertex AI API and creates a Batch Prediction Job.
  5. Vertex AI processes the file asynchronously.
  6. Results are written to an output bucket.
  7. Monitoring and alerts can track job status and failures.

Prerequisites

Before proceeding, ensure you have:

  • Google Cloud Project
  • Billing enabled
  • Vertex AI API enabled
  • Cloud Run API enabled
  • Eventarc API enabled
  • Cloud Storage bucket
  • Appropriate IAM permissions
  • Python 3.10 or later

Install the Vertex AI SDK:

Authenticate locally:

Step 1: Create an Input File

Vertex AI Batch Prediction commonly accepts JSONL files.

Example:

input.jsonl

Upload the file:

Step 2: Create the Cloud Run Service

The Cloud Run service receives Cloud Storage events and creates a Vertex AI Batch Prediction Job.

Create a file named main.py.

Step 3: Create a Requirements File

Create a file named requirements.txt.

Step 4: Create a Dockerfile

Cloud Run requires a container image.

Step 5: Deploy Cloud Run

Deploy the service:

After deployment, note the generated service URL.

Step 6: Configure Eventarc Trigger

Create an Eventarc trigger that listens for file uploads.

Now every time a file is uploaded to the bucket, Eventarc automatically invokes Cloud Run.

Step 7: Upload a Test File

Upload a sample JSONL file.

Cloud Run receives the event and submits a Vertex AI Batch Prediction Job.

Step 8: Monitor the Batch Job

List jobs:

Describe a specific job:

Possible job states:

State Description
PENDING Job created
RUNNING Processing started
SUCCEEDED Completed successfully
FAILED Job failed
CANCELLED Job cancelled

Step 9: Review Prediction Output

Once the job completes, Vertex AI stores the output files in the configured destination bucket.
Example output:

Analytics systems, dashboards, databases, or downstream applications can consume these prediction files.

IAM Permissions Required

The Cloud Run service account should have the following permissions:

Vertex AI Access: roles/aiplatform.user

Read Input Files: roles/storage.objectViewer

Write Output Files: roles/storage.objectAdmin

Eventarc Invocation: roles/eventarc.eventReceiver

Following the principle of least privilege is recommended for production environments.

Benefits of This Architecture

This serverless design offers several advantages:

Fully Automated

No manual intervention is required after the file is uploaded.

Scalable

Cloud Run automatically scales based on incoming events.

Cost Efficient

Cloud Run runs only when needed, and Vertex AI Batch Prediction processes workloads asynchronously.

Easy to Maintain

No VM management or infrastructure provisioning is required.

Enterprise Ready

Supports monitoring, logging, IAM controls, and CI/CD integration.

Conclusion

Vertex AI Batch Prediction provides a simple and scalable way to process large datasets using machine learning models without maintaining dedicated inference infrastructure. By integrating Cloud Storage, Eventarc, and Cloud Run, organisations can build a fully automated event-driven pipeline that automatically submits batch prediction jobs whenever new data arrives.

This architecture is particularly useful for document processing, recommendation engines, content analysis, customer feedback classification, and generative AI workloads. The combination of serverless automation and managed AI services enables teams to focus on business outcomes rather than infrastructure management.

As machine learning workloads continue to grow, automated batch prediction pipelines provide a reliable, scalable, and cost-effective foundation for enterprise AI solutions.

Upskill Your Teams with Enterprise-Ready Tech Training Programs

  • Team-wide Customizable Programs
  • Measurable Business Outcomes
Learn More

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As an AWS Premier Tier Services Partner, AWS Advanced Training Partner, Microsoft Solutions Partner, and Google Cloud Platform Partner, CloudThat has empowered over 1.1 million professionals through 1000+ cloud certifications, winning global recognition for its training excellence, including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 14 awards in the last 9 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, Security, IoT, and advanced technologies like Gen AI & AI/ML. It has delivered over 750 consulting projects for 850+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

FAQs

1. When should I use Batch Prediction instead of Online Prediction?

ANS: – Use Batch Prediction when processing large datasets asynchronously and when low-latency responses are not required. Online Prediction is better suited for real-time applications such as chatbots, recommendation APIs, and interactive applications.

2. Can Vertex AI Batch Prediction process files automatically when they are uploaded?

ANS: – Yes. By combining Cloud Storage, Eventarc, and Cloud Run, you can automatically trigger the creation of Batch Prediction Jobs whenever new files are uploaded to a bucket, creating a fully serverless workflow.

3. What file formats are supported by Vertex AI Batch Prediction?

ANS: – Vertex AI supports multiple input formats depending on the model type, including JSONL, CSV, BigQuery tables, and Cloud Storage-based datasets. JSONL is commonly used for machine learning and generative AI batch inference workloads.

WRITTEN BY Aishwarya M

Aishwarya M works as a Cloud Solutions Architect – DevOps & Kubernetes at CloudThat. She is a proficient DevOps professional with expertise in designing scalable, secure, and automated infrastructure solutions across multi-cloud environments. Aishwarya specializes in leveraging tools like Kubernetes, Terraform, CI/CD pipelines, and monitoring stacks to streamline software delivery and ensure high system availability. She has a deep understanding of cloud-native architectures and focuses on delivering efficient, reliable, and maintainable solutions. Outside of work, Aishwarya enjoys traveling and cooking, exploring new places and cuisines while staying updated with the latest trends in cloud and DevOps technologies.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!