Tag: Azure

  • Secure Azure setup with Entra ID, Bastion, and private VM


    Scope

    Stand up a fresh Azure landing zone with a minimal but secure baseline: Entra ID (Azure AD) hardening, management structure, logging, networking, a Windows/Linux VM without public exposure, and safe access (Bastion + Entra sign-in).

    Placeholders to replace:
    TENANT_NAME · MG_ROOT · SUB_NAME · RG_CORE · RG_NET · RG_VM · LOCATION · VNET_NAME · SUBNET_APP · BASTION_SUBNET · VM_NAME · VM_SIZE · ADMIN_GROUP_OBJECTID


    0) Prereqs

    • Azure tenant & subscription created (via portal/Commerce).
    • Azure CLI logged in: az login az account set --subscription "SUB_NAME"
    • Optional SKUs: Entra ID P1/P2 for Conditional Access, PIM, Identity Protection.

    1) Entra ID (Tenant) Baseline

    • Create two break-glass cloud-only Global Admin accounts; long passwords; exclude from CA; store offline.
    • Turn on Security Defaultsor implement baseline Conditional Access:
      • Require MFA for admins.
      • Disable legacy/basic auth.
      • Require MFA for all users or at least privileged roles.
    • Enable SSPR, passwordless Authenticator (and FIDO2 keys if available).
    • Use PIM for role activation (P2).
    • Create AAD groups for RBAC (e.g., Azure-VM-Admins).

    (Portal-driven; no commands included to keep this redacted.)


    2) Management Structure & Tags

    • Create management group root and place the subscription under it.
    • Standardize tags (Owner, CostCenter, Env, DataClass).
    az account management-group create -n MG_ROOT
    az account management-group subscription add --name MG_ROOT --subscription "SUB_NAME"
    

    3) Core Resource Groups & Logging

    az group create -n RG_CORE -l LOCATION
    az group create -n RG_NET  -l LOCATION
    az group create -n RG_VM   -l LOCATION
    
    # Log Analytics workspace
    az monitor log-analytics workspace create -g RG_CORE -n LAW-CORE -l LOCATION
    LAW_ID=$(az monitor log-analytics workspace show -g RG_CORE -n LAW-CORE --query id -o tsv)
    
    # Send Activity Logs to LAW
    az monitor diagnostic-settings create \
      --name "activity-to-law" \
      --resource "/subscriptions/$(az account show --query id -o tsv)" \
      --workspace $LAW_ID \
      --logs '[{"categoryGroup":"allLogs","enabled":true}]'
    

    4) Guardrails with Azure Policy (minimal starter)

    # Require tags
    az policy assignment create -g RG_CORE -n require-tags \
      --policy "Require a tag and its value on resources" \
      --params '{"tagName":{"value":"Owner"},"tagValue":{"value":"REDACTED"}}'
    
    # Allowed locations
    az policy assignment create -g RG_CORE -n allowed-locations \
      --policy "Allowed locations" \
      --params '{"listOfAllowedLocations":{"value":["LOCATION"]}}'
    

    Enable Microsoft Defender for Cloud and auto-provision agents (portal) to get JIT VM access recommendations and secure score.


    5) Networking (no public RDP/SSH)

    # VNet + subnets
    az network vnet create -g RG_NET -n VNET_NAME -l LOCATION \
      --address-prefixes 10.10.0.0/16 \
      --subnet-name SUBNET_APP --subnet-prefix 10.10.10.0/24
    
    # Dedicated Bastion subnet (must be exactly AzureBastionSubnet)
    az network vnet subnet create -g RG_NET --vnet-name VNET_NAME \
      -n AzureBastionSubnet --address-prefixes 10.10.254.0/27
    
    # NSG and rules (deny inbound by default; allow vnet)
    az network nsg create -g RG_NET -n NSG-APP
    az network nsg rule create -g RG_NET --nsg-name NSG-APP -n Allow-VNet \
      --priority 100 --access Allow --direction Inbound --protocol '*' \
      --source-address-prefixes VirtualNetwork --source-port-ranges '*' \
      --destination-address-prefixes VirtualNetwork --destination-port-ranges '*'
    
    # Associate NSG to the app subnet
    az network vnet subnet update -g RG_NET --vnet-name VNET_NAME -n SUBNET_APP \
      --network-security-group NSG-APP
    

    6) Bastion (safe console access)

    # Public IP for Bastion
    az network public-ip create -g RG_NET -n pip-bastion -l LOCATION --sku Standard --zone 1 2 3
    
    # Bastion host
    az network bastion create -g RG_NET -n bas-VNET_NAME -l LOCATION \
      --public-ip-address pip-bastion --vnet-name VNET_NAME
    

    7) VM (managed identity, no public IP, Entra login)

    Windows example:

    # NIC (no public IP)
    az network nic create -g RG_VM -n nic-VM_NAME \
      --vnet-name VNET_NAME --subnet SUBNET_APP
    
    # VM
    az vm create -g RG_VM -n VM_NAME \
      --image Win2022Datacenter --size VM_SIZE \
      --nics nic-VM_NAME --assign-identity \
      --admin-username "localadmin" --admin-password "GENERATE-STRONG-PASSWORD" \
      --enable-agent true --os-disk-size-gb 128
    
    # Enable AAD login extension (Windows)
    az vm extension set -g RG_VM -n AADLoginForWindows --publisher Microsoft.Azure.ActiveDirectory \
      --vm-name VM_NAME
    
    # Grant Entra groups the VM login roles
    VM_ID=$(az vm show -g RG_VM -n VM_NAME --query id -o tsv)
    az role assignment create --assignee-object-id ADMIN_GROUP_OBJECTID \
      --role "Virtual Machine Administrator Login" --scope $VM_ID
    

    Linux example (SSH keys + AAD login):

    az vm create -g RG_VM -n VM_NAME \
      --image Ubuntu2204 --size VM_SIZE \
      --nics nic-VM_NAME --assign-identity \
      --authentication-type ssh --ssh-key-values ~/.ssh/id_rsa.pub
    
    # Enable AAD SSH login (Linux)
    az vm extension set -g RG_VM -n AADSSHLoginForLinux --publisher Microsoft.Azure.ActiveDirectory \
      --vm-name VM_NAME
    
    # RBAC for login
    az role assignment create --assignee-object-id ADMIN_GROUP_OBJECTID \
      --role "Virtual Machine Administrator Login" --scope $VM_ID
    

    Accessing the VM (no public IP):

    • Portal → Resource → ConnectBastion → Open session (RDP for Windows, SSH for Linux).
    • Optionally enable Just-In-Time in Defender for Cloud; keep NSG closed otherwise.

    8) Backup, Patching, and Keys

    # Recovery Services vault + VM backup
    az backup vault create -g RG_CORE -n rsv-core -l LOCATION
    az backup protection enable-for-vm -g RG_CORE -v rsv-core --vm VM_NAME --policy-name "DefaultPolicy"
    
    # VM guest patching (Update Manager) – enable in portal for the RG/VM
    
    • Store secrets/keys in Azure Key Vault; use managed identity from the VM to fetch secrets.
    • Use Server-side encryption (SSE) with platform-managed keys (default) or customer-managed keys (CMK) via Key Vault if required.

    9) Monitoring (Guest + Platform)

    # Enable VM Insights / Diagnostics to LAW
    az monitor diagnostic-settings create \
      --name "vm-to-law" \
      --resource $VM_ID --workspace $LAW_ID \
      --metrics '[{"category":"AllMetrics","enabled":true}]' \
      --logs '[{"categoryGroup":"allLogs","enabled":true}]'
    

    10) Cost Guardrails

    • Create a Budget in Cost Management with email alerts at 50/80/100%.
    • Consider Reservations and Auto-shutdown on dev/test VMs.

    11) Access Patterns to Prefer

    • Bastion or Private endpoints; avoid public RDP/SSH.
    • Entra sign-in to VMs with RBAC (Virtual Machine User/Administrator Login).
    • PIM + MFA for privileged roles.
    • JIT for any temporary inbound need.

    Minimal Tear-down (lab)

    # Danger: deletes resources
    az group delete -n RG_VM  -y
    az group delete -n RG_NET -y
    az group delete -n RG_CORE -y
    

    Notes & Deviations

    • For domain-join scenarios, use Entra ID DS (managed domain) or a full AD DS in Azure; keep DCs on a separate subnet with restricted NSG.
    • For Intune/MDM of servers, consider Azure Arc + Defender for Endpoint.
    • Replace all placeholders and remove screenshots/IDs before publishing externally.

    For more info:
    Microsoft Entra ID overview/service description. Microsoft Learn
    • Connect to a VM using Azure Bastion (private IP). Microsoft Learn
    • Private Endpoint / Private Link overview & quickstart. Microsoft Learn+1


    © 2012–2025 Jet Mariano. All rights reserved.
    For usage terms, please see the Legal Disclaimer.

  • 🌥️ The Cloud Above Us

    PIMCO (Newport Beach HQ, CA) 🌍 — Global financial services supporting regions in NA, EMEA, APAC.
    Church (Riverton Office Building, UT) ⛪ — Worldwide infrastructure with 200k employees and over 80k missionaries.
    Monster Energy (Corona HQ, CA) ⚡ — Global enterprise IT operations across NA, EMEA, APAC.
    City National Bank (Downtown LA, CA) 🏙️ — U.S. banking systems at scale.

    A journey across scales: national (CNB), global (PIMCO & Monster Energy), and worldwide (The Church).


    Every IT career tells a story, and mine has moved through three different scales of impact:

    Company-Level Foundations → At PayForward, I migrated an entire OnPrem environment into AWS. That meant setting up VPCs, building HA Exchange clusters with load balancers, and proving the power of cloud for a fast-moving startup.

    Regional / Global Scale → At Monster Energy and PIMCO, the work stretched across North America, EMEA, and APAC. The systems never slept. VMware clusters and M365 tenants had to function as one, even though users were scattered across time zones and continents.

    Worldwide Reach → At the Church, the scale expanded beyond regions. Over 200,000 employees and over 80,000 missionaries, connected by systems that had to reach every corner of the globe, demanded both technical precision and spiritual responsibility.

    This journey shows that the “cloud above us” isn’t just AWS, Azure, or GCP — it’s the ability to design, secure, and sustain systems at every possible scale.

    A colleague once told me: “Automate, or eliminate.” In IT, that isn’t just a clever saying — it’s survival. At the scale of hundreds or even thousands of VMs, EC2 instances, or mailboxes, doing things manually is not just unrealistic — it’s risky. What automation can finish in under 10 minutes might take days or weeks by hand, and even then would be prone to errors.

    That’s why Python, PowerShell, Bash, and automation frameworks became part of my daily toolkit. Not to flaunt, but because without automation, no single engineer could handle the demands of environments as large as PIMCO, Monster Energy, or the Church.


    Snippet 1: AWS (My PayForward Days)

    import boto3
    
    # Connect to AWS S3
    s3 = boto3.client('s3')
    
    # List buckets
    buckets = s3.list_buckets()
    print("Your AWS buckets:")
    for bucket in buckets['Buckets']:
        print(f"  {bucket['Name']}")
    

    From racks of servers to a few lines of Python—that’s the power of AWS.

    Snippet 2: PowerShell + Azure (My Church Years, CNB)

    Connect-AzAccount
    Get-AzResourceGroup | Select ResourceGroupName, Location
    

    One line, and you can see every Azure resource group spread across the world. A task that once required data center visits and clipboards is now just a command away.

    Snippet 3: PHP + GCP (Expanding Horizons)

    use Google\Cloud\Storage\StorageClient;
    
    $storage = new StorageClient([
        'keyFilePath' => 'my-service-account.json'
    ]);
    
    $buckets = $storage->buckets();
    
    foreach ($buckets as $bucket) {
        echo $bucket->name() . PHP_EOL;
    }
    

    Snippet 4: VMware + M365 (Monster Energy, PIMCO, and Beyond)

    # Connect to vCenter and list VMs across data centers
    Connect-VIServer -Server vcenter.global.company.com -User admin -Password pass
    Get-VM | Select Name, PowerState, VMHost, Folder
    
    # Quick check of licensed users in M365 (global tenants)
    Connect-MgGraph -Scopes "User.Read.All"
    Get-MgUser -All -Property DisplayName, UserPrincipalName, UsageLocation |
        Group-Object UsageLocation |
        Select Name, Count
    

    One script, and suddenly you’re seeing footprints of users spread across the globe — NA, EMEA, APAC, or even worldwide. That’s the reality of modern IT infrastructure.


    The “cloud above us” is both a literal technology — AWS, Azure, and GCP that I’ve worked across — and a metaphor. It represents resilience, scalability, and unseen support. Just as automation carries workloads we could never handle by hand, life has storms we cannot carry alone.

    From startups making their first move to the cloud, to global financial institutions, to worldwide organizations with hundreds of thousands of users, the lesson is the same: we are not meant to fight every battle manually.

    We are given tools, teammates, and even unseen strength from above to keep moving forward. The same way a script can manage thousands of servers or accounts without error, trust and preparation help us navigate the storms of life with less fear.

    ☁️ Above every storm, there’s always a cloud carrying potential. And above that cloud, always light waiting to break through.

    Before my cloud journey, I also spent nine years in forensic IT supporting law enforcement — a grounding reminder that technology isn’t only about systems and scale, but about accountability and truth.

    © 2012–2025 Jet Mariano. All rights reserved.
    For usage terms, please see the Legal Disclaimer.

error: Content is protected !!