Skip to content

Instantly share code, notes, and snippets.

@abombss
Last active September 22, 2015 18:33
Show Gist options
  • Save abombss/c61c23803c5ddb0fb10e to your computer and use it in GitHub Desktop.
Save abombss/c61c23803c5ddb0fb10e to your computer and use it in GitHub Desktop.
Get Available Azure Resource Manager Schemas
function Get-AzureRmResourceReference {
[CmdletBinding(DefaultParameterSetName='Version')]
param(
[Parameter(Mandatory=$false, Position=0, ParameterSetName='Version')]
[string]$Version='2015-01-01',
[Parameter(Mandatory=$true, Position=0, ParameterSetName='Uri')]
[uri]$Uri,
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ParameterSetName='Content')]
[string]$Content,
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ParameterSetName='Schema')]
[psobject]$Schema
)
begin {
if ($PSCmdlet.ParameterSetName -eq 'Version') {
$Uri = [uri]"http://schema.management.azure.com/schemas/$Version/deploymentTemplate.json"
}
if ($PSCmdlet.ParameterSetName -in @('Version', 'Uri')) {
$Schema = Invoke-RestMethod $Uri
}
if ($PSCmdlet.ParameterSetName -eq 'Content') {
$Schema = $Content | ConvertFrom-Json
}
function Find-Refs {
[CmdletBinding()]
param([Parameter(ValueFromPipeline=$true)]$item)
process {
Write-Verbose "Finding Ref $item"
if ($item.allOf) {
$item.allOf | Find-Refs
}
if ($item.oneOf) {
$item.oneOf | Find-Refs
}
$item |? '$ref' | select-object -exp '$ref'|? { $_.StartsWith('http://') }
}
}
}
process {
$Schema.properties.resources.items.oneOf | Find-Refs |% {
Write-Verbose "Processing Resource `$Ref $_"
[uri] $ref = $_
$ns = $ref.Segments[3].Replace(".json", "").Trim('/')
$apiVersion = $ref.Segments[2].Trim('/')
$name = $ref.Fragment.Substring($ref.Fragment.IndexOf('/', 2) + 1)
$schemaUrl = $ref.GetLeftPart([UriPartial]::Path)
$resource = [PSCustomObject]@{
FullName = "$ns.$name"
Name = $name
Namespace = $ns
ApiVersion = $apiVersion
FullyQualifiedName = "$ns.$name, $apiVersion"
Schema = $ref
SchemaUrl = $schemaUrl
}
$resource.PSObject.TypeNames.Insert(0, 'Azure.ResourceManager.ResourceRef')
Write-Output $resource
}
}
end { }
}
The MIT License (MIT)
Copyright (c) 2015 Adam Tybor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
[
{
"FullName": "Microsoft.Web.certificates",
"Name": "certificates",
"Namespace": "Microsoft.Web",
"ApiVersion": "2014-06-01",
"Schema": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json#/definitions/certificates",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json"
},
{
"FullName": "Microsoft.Web.serverfarms",
"Name": "serverfarms",
"Namespace": "Microsoft.Web",
"ApiVersion": "2014-06-01",
"Schema": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json#/definitions/serverfarms",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json"
},
{
"FullName": "Microsoft.Web.certificates",
"Name": "certificates",
"Namespace": "Microsoft.Web",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Web.json#/definitions/certificates",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Web.json"
},
{
"FullName": "Microsoft.Web.serverfarms",
"Name": "serverfarms",
"Namespace": "Microsoft.Web",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Web.json#/definitions/serverfarms",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Web.json"
},
{
"FullName": "Microsoft.Sql.databases",
"Name": "databases",
"Namespace": "Microsoft.Sql",
"ApiVersion": "2014-04-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json#/definitions/databases",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json"
},
{
"FullName": "Microsoft.Sql.firewallrules",
"Name": "firewallrules",
"Namespace": "Microsoft.Sql",
"ApiVersion": "2014-04-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json#/definitions/firewallrules",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json"
},
{
"FullName": "Microsoft.Insights.alertrules",
"Name": "alertrules",
"Namespace": "Microsoft.Insights",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json#/definitions/alertrules",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json"
},
{
"FullName": "Microsoft.Insights.components",
"Name": "components",
"Namespace": "Microsoft.Insights",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json#/definitions/components",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json"
},
{
"FullName": "Microsoft.Insights.autoscalesettings",
"Name": "autoscalesettings",
"Namespace": "Microsoft.Insights",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json#/definitions/autoscalesettings",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json"
},
{
"FullName": "Microsoft.Insights.webtests",
"Name": "webtests",
"Namespace": "Microsoft.Insights",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json#/definitions/webtests",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Insights.json"
},
{
"FullName": "microsoft.visualstudio.account",
"Name": "account",
"Namespace": "microsoft.visualstudio",
"ApiVersion": "2014-02-26",
"Schema": "http://schema.management.azure.com/schemas/2014-02-26/microsoft.visualstudio.json#/definitions/account",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-02-26/microsoft.visualstudio.json"
},
{
"FullName": "Microsoft.Cache.Redis",
"Name": "Redis",
"Namespace": "Microsoft.Cache",
"ApiVersion": "2014-04-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Cache.json#/definitions/Redis",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Cache.json"
},
{
"FullName": "Microsoft.BizTalkServices.BizTalk",
"Name": "BizTalk",
"Namespace": "Microsoft.BizTalkServices",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.BizTalkServices.json#/definitions/BizTalk",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.BizTalkServices.json"
},
{
"FullName": "Microsoft.BizTalkServices.HybridConnection",
"Name": "HybridConnection",
"Namespace": "Microsoft.BizTalkServices",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.BizTalkServices.json#/definitions/HybridConnection",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.BizTalkServices.json"
},
{
"FullName": "Microsoft.AppService.apiapps",
"Name": "apiapps",
"Namespace": "Microsoft.AppService",
"ApiVersion": "2015-03-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2015-03-01-preview/Microsoft.AppService.json#/definitions/apiapps",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-03-01-preview/Microsoft.AppService.json"
},
{
"FullName": "Microsoft.AppService.registrations",
"Name": "registrations",
"Namespace": "Microsoft.AppService",
"ApiVersion": "2015-03-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2015-03-01-preview/Microsoft.AppService.json#/definitions/registrations",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-03-01-preview/Microsoft.AppService.json"
},
{
"FullName": "Microsoft.NotificationHubs.notificationHubs",
"Name": "notificationHubs",
"Namespace": "Microsoft.NotificationHubs",
"ApiVersion": "2015-04-01",
"Schema": "http://schema.management.azure.com/schemas/2015-04-01/Microsoft.NotificationHubs.json#/definitions/notificationHubs",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-04-01/Microsoft.NotificationHubs.json"
},
{
"FullName": "Microsoft.DataConnect.connectionManagers",
"Name": "connectionManagers",
"Namespace": "Microsoft.DataConnect",
"ApiVersion": "2015-08-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01-preview/Microsoft.DataConnect.json#/definitions/connectionManagers",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01-preview/Microsoft.DataConnect.json"
},
{
"FullName": "Microsoft.Network.publicIPAddresses",
"Name": "publicIPAddresses",
"Namespace": "Microsoft.Network",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json#/definitions/publicIPAddresses",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json"
},
{
"FullName": "Microsoft.Network.virtualNetworks",
"Name": "virtualNetworks",
"Namespace": "Microsoft.Network",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json#/definitions/virtualNetworks",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json"
},
{
"FullName": "Microsoft.Network.loadBalancers",
"Name": "loadBalancers",
"Namespace": "Microsoft.Network",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json#/definitions/loadBalancers",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json"
},
{
"FullName": "Microsoft.Network.networkSecurityGroups",
"Name": "networkSecurityGroups",
"Namespace": "Microsoft.Network",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json#/definitions/networkSecurityGroups",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json"
},
{
"FullName": "Microsoft.Network.networkInterfaces",
"Name": "networkInterfaces",
"Namespace": "Microsoft.Network",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json#/definitions/networkInterfaces",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Network.json"
},
{
"FullName": "Microsoft.Storage.storageAccounts",
"Name": "storageAccounts",
"Namespace": "Microsoft.Storage",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Storage.json#/definitions/storageAccounts",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Storage.json"
},
{
"FullName": "Microsoft.Compute.availabilitySets",
"Name": "availabilitySets",
"Namespace": "Microsoft.Compute",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json#/definitions/availabilitySets",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json"
},
{
"FullName": "Microsoft.Compute.extensions",
"Name": "extensions",
"Namespace": "Microsoft.Compute",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json#/definitions/extensions",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json"
},
{
"FullName": "Microsoft.Web.sites",
"Name": "sites",
"Namespace": "Microsoft.Web",
"ApiVersion": "2014-06-01",
"Schema": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json#/definitions/sites",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json"
},
{
"FullName": "Microsoft.Web.sites",
"Name": "sites",
"Namespace": "Microsoft.Web",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Web.json#/definitions/sites",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Web.json"
},
{
"FullName": "Microsoft.Sql.servers",
"Name": "servers",
"Namespace": "Microsoft.Sql",
"ApiVersion": "2014-04-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json#/definitions/servers",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json"
},
{
"FullName": "Microsoft.Scheduler.jobCollections",
"Name": "jobCollections",
"Namespace": "Microsoft.Scheduler",
"ApiVersion": "2014-08-01",
"Schema": "http://schema.management.azure.com/schemas/2014-08-01/Microsoft.Scheduler.json#/definitions/jobCollections",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-08-01/Microsoft.Scheduler.json"
},
{
"FullName": "Microsoft.AppService.gateways",
"Name": "gateways",
"Namespace": "Microsoft.AppService",
"ApiVersion": "2015-03-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2015-03-01-preview/Microsoft.AppService.json#/definitions/gateways",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-03-01-preview/Microsoft.AppService.json"
},
{
"FullName": "Microsoft.NotificationHubs.namespaces",
"Name": "namespaces",
"Namespace": "Microsoft.NotificationHubs",
"ApiVersion": "2015-04-01",
"Schema": "http://schema.management.azure.com/schemas/2015-04-01/Microsoft.NotificationHubs.json#/definitions/namespaces",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-04-01/Microsoft.NotificationHubs.json"
},
{
"FullName": "Microsoft.Compute.virtualMachines",
"Name": "virtualMachines",
"Namespace": "Microsoft.Compute",
"ApiVersion": "2015-08-01",
"Schema": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json#/definitions/virtualMachines",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json"
},
{
"FullName": "SuccessBricks.ClearDB.databases",
"Name": "databases",
"Namespace": "SuccessBricks.ClearDB",
"ApiVersion": "2014-04-01",
"Schema": "http://schema.management.azure.com/schemas/2014-04-01/SuccessBricks.ClearDB.json#/definitions/databases",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-04-01/SuccessBricks.ClearDB.json"
},
{
"FullName": "Microsoft.Resources.deployments",
"Name": "deployments",
"Namespace": "Microsoft.Resources",
"ApiVersion": "2015-01-01",
"Schema": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/definitions/deployments",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json"
},
{
"FullName": "Microsoft.Resources.links",
"Name": "links",
"Namespace": "Microsoft.Resources",
"ApiVersion": "2015-01-01",
"Schema": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/definitions/links",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json"
},
{
"FullName": "Microsoft.Authorization.locks",
"Name": "locks",
"Namespace": "Microsoft.Authorization",
"ApiVersion": "2015-01-01",
"Schema": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json#/definitions/locks",
"SchemaUrl": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json"
},
{
"FullName": "Microsoft.Authorization.roleAssignments",
"Name": "roleAssignments",
"Namespace": "Microsoft.Authorization",
"ApiVersion": "2014-10-01-preview",
"Schema": "http://schema.management.azure.com/schemas/2014-10-01-preview/Microsoft.Authorization.json#/definitions/roleAssignments",
"SchemaUrl": "http://schema.management.azure.com/schemas/2014-10-01-preview/Microsoft.Authorization.json"
}
]
Get-AzureRmResourceReference -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment