Last active
January 2, 2026 04:31
-
-
Save punitganshani/efa595ca122364fba448b004acf8419b to your computer and use it in GitHub Desktop.
Foundry Model Availability Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get Azure AI Foundry Model Availability by Region | |
| # This script queries Azure AI model availability (OpenAI, AI Services, etc.) across regions and outputs to CSV | |
| param( | |
| [string]$OutputFile = "foundry-model-availability.csv", | |
| [switch]$IncludeCapacity | |
| ) | |
| Write-Host "Querying Azure AI Foundry model availability..." -ForegroundColor Cyan | |
| # Check if logged into Azure | |
| $account = az account show 2>$null | ConvertFrom-Json | |
| if (-not $account) { | |
| Write-Error "Not logged into Azure. Please run 'az login' first." | |
| exit 1 | |
| } | |
| Write-Host "Using subscription: $($account.name) ($($account.id))" -ForegroundColor Green | |
| # Get all Azure regions that support Cognitive Services | |
| Write-Host "Fetching available regions..." -ForegroundColor Cyan | |
| $regions = az account list-locations --query "[?metadata.regionType=='Physical'].name" -o json | ConvertFrom-Json | |
| # Initialize results array | |
| $results = @() | |
| # Common AI regions to prioritize | |
| $priorityRegions = @( | |
| 'malaysiawest', 'southeastasia', 'japaneast', 'eastus2' | |
| ) | |
| # Filter to priority regions or all if specified | |
| $regionsToCheck = $regions | Where-Object { $priorityRegions -contains $_ } | |
| Write-Host "Checking $($regionsToCheck.Count) regions for model availability..." -ForegroundColor Cyan | |
| foreach ($region in $regionsToCheck) { | |
| Write-Host " Checking region: $region" -ForegroundColor Gray | |
| try { | |
| # Query model catalog using Azure REST API for all AI models | |
| $apiUrl = "https://management.azure.com/subscriptions/$($account.id)/providers/Microsoft.CognitiveServices/locations/$region/models?api-version=2023-05-01" | |
| $response = az rest --method GET --url $apiUrl -o json 2>$null | |
| if ($response) { | |
| $modelData = $response | ConvertFrom-Json | |
| if ($modelData.value -and $modelData.value.Count -gt 0) { | |
| Write-Host " Found $($modelData.value.Count) models" -ForegroundColor Green | |
| foreach ($item in $modelData.value) { | |
| # Extract model details | |
| $modelName = if ($item.model.name) { $item.model.name } elseif ($item.name) { $item.name } else { "Unknown" } | |
| $modelVersion = if ($item.model.version) { $item.model.version } else { "N/A" } | |
| $modelFormat = if ($item.model.format) { $item.model.format } else { "N/A" } | |
| $skuName = if ($item.model.skus -and $item.model.skus.Count -gt 0) { $item.model.skus[0].name } else { "N/A" } | |
| $modelKind = if ($item.kind) { $item.kind } else { "N/A" } | |
| # Include all AI models (OpenAI, Azure AI Services, etc.) | |
| $results += [PSCustomObject]@{ | |
| Region = $region | |
| ModelName = $modelName | |
| Version = $modelVersion | |
| Format = $modelFormat | |
| SKU = $skuName | |
| Kind = $modelKind | |
| Available = "Yes" | |
| Timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") | |
| } | |
| } | |
| } | |
| else { | |
| Write-Host " No models found in API response" -ForegroundColor Yellow | |
| } | |
| } | |
| else { | |
| Write-Host " No response from API" -ForegroundColor Yellow | |
| } | |
| # Also query Azure AI Services kinds available | |
| Write-Host " Checking AI Services kinds..." -ForegroundColor Gray | |
| $kindsUrl = "https://management.azure.com/subscriptions/$($account.id)/providers/Microsoft.CognitiveServices/locations/$region/skus?api-version=2023-05-01" | |
| $kindsResponse = az rest --method GET --url $kindsUrl -o json 2>$null | |
| if ($kindsResponse) { | |
| $kindsData = $kindsResponse | ConvertFrom-Json | |
| if ($kindsData.value -and $kindsData.value.Count -gt 0) { | |
| Write-Host " Found $($kindsData.value.Count) service kinds" -ForegroundColor Green | |
| foreach ($kindItem in $kindsData.value) { | |
| # Add service kinds as separate entries | |
| $serviceName = if ($kindItem.kind) { $kindItem.kind } elseif ($kindItem.name) { $kindItem.name } else { "Unknown" } | |
| $tier = if ($kindItem.tier) { $kindItem.tier } else { "N/A" } | |
| # Only add unique combinations | |
| $exists = $results | Where-Object { $_.Region -eq $region -and $_.ModelName -eq $serviceName -and $_.Kind -eq $serviceName } | |
| if (-not $exists) { | |
| $results += [PSCustomObject]@{ | |
| Region = $region | |
| ModelName = $serviceName | |
| Version = "N/A" | |
| Format = "Service" | |
| SKU = $tier | |
| Kind = $serviceName | |
| Available = "Yes" | |
| Timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| catch { | |
| Write-Warning "Failed to query region $region : $_" | |
| } | |
| } | |
| # Export to CSV | |
| if ($results.Count -gt 0) { | |
| $results | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8 | |
| Write-Host "`nSuccess! Found $($results.Count) model/region combinations" -ForegroundColor Green | |
| Write-Host "Results exported to: $OutputFile" -ForegroundColor Green | |
| # Display summary | |
| Write-Host "`nSummary:" -ForegroundColor Cyan | |
| $uniqueModels = ($results | Select-Object -ExpandProperty ModelName -Unique).Count | |
| $uniqueRegions = ($results | Select-Object -ExpandProperty Region -Unique).Count | |
| Write-Host " Unique Models: $uniqueModels" -ForegroundColor White | |
| Write-Host " Regions Checked: $uniqueRegions" -ForegroundColor White | |
| # Show top models by availability | |
| Write-Host "`nTop Models by Region Availability:" -ForegroundColor Cyan | |
| $results | Group-Object ModelName | | |
| Sort-Object Count -Descending | | |
| Select-Object -First 15 | | |
| ForEach-Object { | |
| Write-Host " $($_.Name): $($_.Count) regions" -ForegroundColor White | |
| } | |
| # Show sample of results | |
| Write-Host "`nSample Results:" -ForegroundColor Cyan | |
| $results | Select-Object -First 5 | Format-Table -AutoSize | |
| } | |
| else { | |
| Write-Warning "No models found in the checked regions." | |
| Write-Host "This might indicate:" -ForegroundColor Yellow | |
| Write-Host " 1. No Azure OpenAI or AI Services resources are available in your subscription" -ForegroundColor Yellow | |
| Write-Host " 2. You may need to request access to Azure OpenAI" -ForegroundColor Yellow | |
| Write-Host " 3. The regions checked may not support these services" -ForegroundColor Yellow | |
| } | |
| Write-Host "`nDone!" -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment