Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get the api versions and locations for a resource type published in the manifest
function api {
<#
.Synopsis
Get the api versions and locations for a resource type.
.Description
Lists all the available api versions and locations for a given resource type. Information is pulled from the /providers api
which returns the information in the manifest published to ARM.
.Notes
The resource parameter requires the format of Namespace/type, e.g. Microsoft.Storage/storageAccounts
> api Microsoft.Storage/storageAccounts
#>
param(
[Parameter(Mandatory = $true)][String]$resource
)
$a = $resource.Split('/', 2)
$ProviderNameSpace = $a[0]
$resourceTypeName = $a[1]
Write-Host $ProviderNameSpace
Write-Host $resourceTypeName
$resourceTypes = (Get-AzResourceProvider -ProviderNamespace $ProviderNameSpace).ResourceTypes
($resourceTypes | where-object { $_.ResourceTypeName -eq "$resourceTypeName" }).apiVersions
$v = ($resourceTypes | where-object { $_.ResourceTypeName -eq "$resourceTypeName" }).locations
$locations = @()
foreach($l in $v){
$locations += $l.replace(" ", "").toLower()
}
$locations | Sort-Object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment