Skip to content

Get-AzResourceProvider does not return defaultApiVersion #26486

@efloresgil

Description

@efloresgil

Description

Description

The Get-AzResourceProvider cmdlet does not make the defaultApiVersion part of the response available in the resulting PsObject

The API itself does return the defaultApiVersion, but the command itself does not:

(Get-AzResourceProvider -Debug -ProviderNamespace "Microsoft.Compute").ResourceTypes[0].PsObject.Properties

Details

It appears the GetAzureProviderCmdlet class method OnProcessRecord does not load that particular part of the response:

new PSResourceProviderResourceType
{
ResourceTypeName = type.ResourceTypeName,
Locations = type.Locations,
ApiVersions = type.ApiVersions,
ZoneMappings = type.ZoneMappings
}

The PSResourceProviderResourceType class itself does not include this property yet.

public class PSResourceProviderResourceType
{
/// <summary>
/// Gets or sets the name of the resource type.
/// </summary>
public string ResourceTypeName { get; set; }
/// <summary>
/// Gets or sets the locations this resource is available in.
/// </summary>
public string[] Locations { get; set; }
/// <summary>
/// Gets or sets the api versions that this resource is supported in.
/// </summary>
public string[] ApiVersions { get; set; }
/// <summary>
/// Gets or sets the zone mappings that this resource supports.
/// </summary>
public Hashtable ZoneMappings { get; set; }
}

However, the ProviderResourceType class used to deserialize the API response does include it already:

[Newtonsoft.Json.JsonProperty(PropertyName = "defaultApiVersion")]
public string DefaultApiVersion {get; private set; }

Issue script & Debug output

You can confirm this behavior by running the following command and comparing the returned properties to the debug API response

(Get-AzResourceProvider -debug -ProviderNamespace "Microsoft.Compute").ResourceTypes[0].PsObject.Properties

Environment data

Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Module versions

ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.4 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 7.5.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get->AzDeployment…}

Error output

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions