GCP Service Accounts & Cloud IAM ➔ Microsoft Entra ID (Azure AD) & Service Principals
From GCP Service Accounts & JSON Keys to Microsoft Entra ID Service Principals, Client Secrets & DefaultAzureCredential.
In GCP, you create a 'Service Account' and download a JSON key file. In Azure, you register an 'App Registration' in Microsoft Entra ID, generate a 'Client Secret' (or use pure `az login`), and grant an Azure RBAC role (e.g. `Storage Blob Data Contributor`) to its 'Service Principal'. In Python, `DefaultAzureCredential()` gives you the exact same automatic multi-environment discovery as Google's ADC!
1. Architectural Mechanism Comparison
GCP Service Accounts & Cloud IAM
Special Google accounts (`name@project.iam.gserviceaccount.com`) used by applications. Authenticated via downloaded JSON private key files or Application Default Credentials (ADC). Permissions assigned via IAM Policy Bindings.
- Uniform identity model: identical syntax for Python SDKs, VM service accounts, and CI/CD pipelines.
- Application Default Credentials (ADC) automatically finds credentials in local dev or production.
- Secret Manager integration for securely fetching API keys and passwords.
Microsoft Entra ID (Azure AD) & Service Principals
App Registrations & Service Principals (SPN). An Application Object acts as the identity blueprint; the Service Principal is the local representation in the tenant. Authenticated via Client Secret (password), Certificate, or Managed Identity. Permissions assigned via Azure RBAC Role Assignments.
- Managed Identity: 100% keyless authentication inside Azure (zero keys on disk, automated rotation).
- `DefaultAzureCredential()` chain automatically tries Environment Variables, Workload Identity, Managed Identity, and local `az login`.
- Granular Azure RBAC with custom roles and POSIX ACL integration on data lakes.
2. Interactive Terminology & Concept Bridge
Interactive Concept Bridge: Terminology & Architectural Mapping
Click any concept below to see how your GCP knowledge directly maps into AZURE.
GCP Service Account (GSA)
`app-bq-loader@my-proj.iam.gserviceaccount.com` representing an application identity.
App Registration & Service Principal (SPN)
An identity in Microsoft Entra ID with an Application (Client) ID and Object ID.
Both represent non-human machine identities used by code, automation, and background services.
3. Visual Architecture Pipeline (Microsoft Entra ID (Azure AD) & Service Principals)
IAM Mental Model: Policy = Principal (“Who”) + Role (“What”) + Resource (“Where”)
Click any section below or run the simulation to see how Google Cloud evaluates IAM policy bindings.
2. The Role ('WHAT' they can do)
Predefined & Custom Roles (Collections of Exact Permissions)
A Role is a collection of fine-grained permissions (e.g. `storage.objects.get`, `bigquery.jobs.create`). Predefined roles are curated by Google, while Custom roles provide surgical least-privilege control.
- •Predefined roles (e.g. `roles/bigquery.dataViewer`) maintained and updated automatically by Google.
- •Custom roles let you bundle exact permissions to enforce strict least-privilege compliance.
- •Primitive roles (`Owner`, `Editor`, `Viewer`) are legacy anti-patterns to avoid in production.
4. Side-by-Side Code, CLI & Terraform Translator
Side-by-Side Code & Syntax Translator
# ========================================================
# GCP: Local Python Script Querying BigQuery
# ========================================================
import os
from google.cloud import bigquery
# Option A: Explicit Service Account JSON key
# os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/sa_key.json"
# Option B: Or run 'gcloud auth application-default login' once on your machine!
# BigQuery client automatically discovers credentials via ADC
client = bigquery.Client(project="my-gcp-project")
query = "SELECT region, SUM(amount) AS total FROM `my-gcp-project.analytics.orders` GROUP BY region"
query_job = client.query(query)
for row in query_job.result():
print(f"Region: {row.region}, Total: {row.total}")# ========================================================
# AZURE: Local Python Script Querying ADLS / Synapse
# ========================================================
import os
from azure.identity import DefaultAzureCredential, ClientSecretCredential
from azure.storage.filedatalake import DataLakeServiceClient
# Option A: Client Secret via Environment Variables
# os.environ["AZURE_TENANT_ID"] = "00000000-0000-0000-0000-000000000000"
# os.environ["AZURE_CLIENT_ID"] = "11111111-1111-1111-1111-111111111111"
# os.environ["AZURE_CLIENT_SECRET"] = "your-generated-secret-value"
# Option B: Or run 'az login' once on your machine!
# DefaultAzureCredential automatically checks:
# 1. Env vars -> 2. Managed Identity -> 3. Local 'az login' CLI!
credential = DefaultAzureCredential()
account_url = "https://mycorpdatalake.dfs.core.windows.net"
service_client = DataLakeServiceClient(account_url, credential=credential)
file_system = service_client.get_file_system_client("curated-data")
paths = file_system.get_paths(path="orders/2026")
for path in paths:
print(f"Found Lake File: {path.name}, Size: {path.content_length} bytes")5. Paradigm Shift Gotchas: Traps to Avoid in AZURE
Azure Client Secret Expiration Deadlines
In GCP, a downloaded `sa_key.json` works indefinitely until deleted. In Azure, Client Secrets have a mandatory expiration date (max 24 months). When it expires, production ETL scripts fail with `AADSTS7000222: The provided client secret keys are expired`!
Set calendar alerts for secret rotation, or eliminate client secrets completely in production by using Azure Managed Identities or Workload Identity Federation.
The Storage Blob Data Contributor vs. Contributor Trap
In Azure, the management plane and data plane are strictly separated. An identity with the broad `Contributor` role can delete the storage account, but if your Python script runs `service_client.get_file_system_client()`, it will fail with 403 Authorization Failure!
Always grant the specific data-plane role: `Storage Blob Data Contributor` (read/write/delete data) or `Storage Blob Data Reader` (read data).
6. Test Your Mental Model
Quick Knowledge Check: Test Your AZURE Mental Model
Solidify your cross-cloud understanding with instant feedback.