Tuesday, February 10, 2026

Azure Cloud Shell - Profile Modifications for non-US Regions

 Azure Cloud Shell is a handy tool, but some of the non-configurable/non-persistent defaults are annoying. en-US locale is one such setting - those date formats are truly awful.

Here's my approach to fix this for Powershell sessions by modifying the session profile. The prompt is modified to ensure the locale is set for each interactive prompt, as setting the CurrentCulture by itself doesn't persist for the session - just for the current pipeline :-(

mkdir -p ~/.config/PowerShell
@'
# Force Australian culture for the entire session
$newc = [System.Globalization.CultureInfo]::new("en-AU")
[System.Threading.Thread]::CurrentThread.CurrentCulture = $newc
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $newc
[System.Globalization.CultureInfo]::CurrentCulture = $newc

# Override the prompt to re-apply culture before every command
function prompt {
    $newc = [System.Globalization.CultureInfo]::new("en-AU")
    [System.Threading.Thread]::CurrentThread.CurrentCulture = $newc
    "PS [en-AU] $($ExecutionContext.SessionState.Path.CurrentLocation)> "
}

# az-local helper to convert UTC to AEST
# examples:
#   List VMs with Local Times:
#     az vm list -o json | az-local | Format-Table Name, timeCreated
#   Check Resource Groups:
#     az group list -o json | az-local | ft name, tags

function az-local {
    param([Parameter(ValueFromPipeline)]$InputObject)
    process {
        $InputObject | ConvertFrom-Json | ForEach-Object {
            $obj = $_
            # Find any property containing 'time' or 'Date' and convert it
            $obj.PSObject.Properties | Where-Object { $_.Name -match "time|date" } | ForEach-Object {
                if ($_.Value -and $_.Value -is [string]) {
                    if ($dt = [datetime]::TryParse($_.Value, [ref][datetime]::MinValue)) {
                        $_.Value = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]$_.Value, [System.TimeZoneInfo]::FindSystemTimeZoneById("AUS Eastern Standard Time")).ToString("dd/MM/yyyy HH:mm:ss")
                    }
                }
            }
            $obj
        }
    }
}
'@ > $PROFILE
. $PROFILE

Modify 'en-AU' and 'AUS Eastern Standard Time' to match your regional settings.
The language tags to use can be found here - Available Language Packs for Windows | Microsoft Learn.
The timezones you can use can be found by running 'tzutil /l' on a Windows device and using the second line of each entry in the call to FindSystemTimeZoneById.

The az-local function helps you convert the UTC times that the 'az' commands generate. See the examples in the comment section in the code above on how to use this.

If your cloud sessions are ephemeral (no storage account mounted), then you'll need to copy-paste this each time you launch a cloud session.



No comments: