Private/Test-StorageAccountAccess.ps1

function Test-StorageAccountAccess {
    <#
    .SYNOPSIS
        Validates that a storage account exists and is accessible via Azure CLI.
    .PARAMETER AccountName
        Name of the Azure Storage Account to check.
    .OUTPUTS
        [void] Throws on failure.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$AccountName
    )

    Write-Host "Checking storage account '$AccountName'..." -ForegroundColor Cyan
    $result = az storage account show --name $AccountName --query 'name' -o tsv 2>&1
    if ($LASTEXITCODE -ne 0) {
        throw "Storage account '$AccountName' is not accessible. Ensure it exists and you have permissions.`n$result"
    }
    Write-Host " ✓ '$AccountName' is accessible." -ForegroundColor Green
}