Migrating my AI portfolio website from Azure to Google Cloud Run

Seif Bassem
Seif Bassem
· 5 min read
Migrating my AI portfolio website from Azure to Google Cloud Run
Table of Contents8

Earlier this year, I shared how I built my AI-powered portfolio website on Azure using Azure Container Apps, Microsoft Foundry, Azure AI Search, and Bicep for under $10/month.

That setup ran reliably, so why move it?

Two reasons: I wanted to cut the monthly hosting bill even further (especially the fixed ~$5/month Azure Container Registry Basic cost), and I wanted a real, production hands-on migration to Google Cloud covering serverless containers, Gemini Platform, Firestore vector search, Terraform, and keyless Workload Identity Federation (WIF).

Instead of doing a risky rip-and-replace, I deployed the Google Cloud stack in parallel alongside Azure, tested everything end-to-end on Cloud Run, cut over Cloudflare DNS with zero downtime, and then cleaned up the old Azure resources.

In this post, I will walk through:

  • 🏗️ Azure to Google Cloud mapping (architecture and key design trade-offs)
  • 🧠 AI pipeline (Gemini Platform gemini-3.8-flash + Firestore Native Vector Search)
  • 🔐 Zero-trust security (private IAM-only Cloud Run backend with OIDC ID tokens and keyless WIF)

Architecture

The high-level flow stays clean and serverless, with Cloudflare at the edge and two scale-to-zero Cloud Run services in europe-west1:

seifbassem.com High-Level Google Cloud Architecture

Azure to Google Cloud Service Mapping

Layer Previous (Azure) New (Google Cloud) Why I Made the Switch
Edge / CDN / WAF Cloudflare (Free) Cloudflare (Free) Unchanged, works identically in front of Cloud Run
Frontend Hosting Azure Container Apps (Astro SSR) Cloud Run v2 (portfolio-web) True scale-to-zero with generous always-free tier
Backend API Azure Container Apps (ingressExternal: false) Cloud Run v2 (portfolio-api, IAM-only) Private service-to-service auth using Google OIDC ID tokens
LLM Inference Microsoft Foundry (DeepSeek-V3.2) Gemini Platform (gemini-3.8-flash + gemini-3.5-flash-lite) Native google-genai SDK via ADC, parameterized in Terraform
Embeddings Microsoft Foundry (text-embedding-ada-002) Gemini Platform (text-embedding-005) 768-dim embeddings matching Firestore vector index
RAG Vector Store Azure AI Search (Free) + Blob Storage Cloud Firestore Native Vector Search Shares the exact same free-tier DB as rate limiting, zero extra services
Rate-Limit Storage Azure Table Storage Cloud Firestore (ratelimits collection) Persistent per-IP SlowAPI counters across cold starts
Container Registry Azure Container Registry (Basic, ~$5/mo) Artifact Registry (europe-west1) 0.5 GB always-free tier with cleanup policy keeping 5 recent versions
Infrastructure as Code Bicep + AVM Terraform + GCS Remote State Clean, portable IaC with isolated bootstrap for GitHub WIF

Key Trade-offs

  • Firestore Native Vector Search vs Gemini Platform Search: I could have used Gemini Platform Search (Discovery Engine) as a 1:1 equivalent to Azure AI Search, or loaded all markdown files directly into Gemini’s 1M context window. Firestore Native Vector Search (find_nearest()) hit the sweet spot: it runs inside the same always-free Firestore database I already needed for rate limiting, indexes both my 25 Markdown files and my resume PDF (68 chunks total), and adds zero extra services to manage.
  • Artifact Registry vs Docker Hub: On Azure, I initially avoided ACR’s ~$5/month cost by pushing to Docker Hub. On Google Cloud, Artifact Registry includes a 0.5 GB always-free tier and native IAM pull from Cloud Run, so with a cleanup policy keeping only the 5 newest versions, it stays free and private with no external registry credentials.
  • Parallel Rollout Before Cutover: Rather than modifying the live Azure deployment in place, I kept all Bicep templates, litellm_app.py, and Azure workflows untouched while building the GCP stack alongside them. Even the Astro OIDC auth helper checks for Cloud Run’s K_SERVICE environment variable and acts as a clean no-op on Azure.

AI Pipeline on Gemini Platform & Firestore

I kept the same cost-efficient two-stage AI pipeline from the Azure version, swapping LiteLLM and the Azure SDKs for Google’s native google-genai SDK and google-cloud-firestore:

User Question -> Stage 1 Classifier (gemini-3.5-flash-lite) -> Firestore Vector Search (COSINE) -> Stage 2 Streaming (gemini-3.8-flash)

Stage 1 filters out off-topic questions with a lightweight gemini-3.5-flash-lite call before touching RAG. For relevant questions, Stage 2 embeds the query with text-embedding-005, retrieves the top matching chunks from Firestore via find_nearest(), and streams the grounded response word-by-word over Server-Sent Events (SSE) using gemini-3.8-flash (thinking_level="LOW"). Both models are parameterized in Terraform so switching models takes a single config change.

Security

Just like the Azure version, keeping costs low did not mean cutting corners on security.

Private Backend with Cloud Run OIDC Auth

On Azure Container Apps, portfolio-api was hidden using internal-only VNet ingress (ingressExternal: false). On Cloud Run, I achieved the same zero-trust boundary without paying for a VPC connector or Load Balancer:

  1. portfolio-api is deployed with --no-allow-unauthenticated (no allUsers invoker). Direct requests to its *.run.app URL immediately return 403 Forbidden.
  2. Only portfolio-web-sa is granted roles/run.invoker on portfolio-api.
  3. On every /api/ask and /api/warmup call, portfolio-web fetches and caches (for 50 minutes) a short-lived Google OIDC ID token from the Cloud Run metadata server:
const metadataUrl =
  `http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity` +
  `?audience=${encodeURIComponent(audience)}`;

const response = await fetch(metadataUrl, {
  headers: { 'Metadata-Flavor': 'Google' },
});

Least-Privilege Service Accounts & Strict Supply Chain Pinning

Security Feature Implementation
No Static Keys Application Default Credentials (ADC) at runtime + Keyless WIF OIDC in GitHub Actions
Dedicated Service Accounts portfolio-web-sa (run.invoker only), portfolio-api-sa (aiplatform.user + datastore.user only)
Private Terraform State GCS bucket with uniform bucket-level access, versioning, and public access prevention enforced
Hardened Containers Multi-stage builds, non-root users, and CI-enforced strict == version pinning in app/requirements.txt

Conclusion

Moving seifbassem.com from Azure to Google Cloud Run let me cut the monthly hosting bill down to roughly $1/month while keeping the same zero-trust security posture, scale-to-zero architecture, and streaming RAG experience.

Having both architectures under my belt (Azure Container Apps + Bicep + Microsoft Foundry, and now Cloud Run + Terraform + Gemini Platform + Firestore) also made it clear how cleanly modern serverless AI patterns translate across clouds when you stick to open standards like containers, OIDC, and IaC.

You can check out the full Google Cloud + Terraform implementation on GitHub.


Want to test the new Gemini 3.8 Flash + Firestore RAG backend? Try the AI assistant on seifbassem.com (just remember there is still a 3/day rate limit 😉).

Enjoyed this article? Share it:

Related Articles