Azure / Azure/azure-powershell

[Az.Resources] [Get-AzResourceProvider] Returns non-existent API versions

Open
#22,581 3 comments 0 reactions 0 assignees View on GitHub
act-identity-squad ARM question Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

The `Get-AzResourceProvider` cmdlet seemingly returns API versions that are either not existing - or - not yet.

We're using the command as part of the [AZureAPICrawler](https://www.powershellgallery.com/packages/AzureAPICrawler/1.0.0) module used in the [CARML](https://aka.ms/carml) module library to check that leveraged API versions are not outdated.
> Trivia: The AzureAPICrawler fetches both the results it finds via the `Get-AzResourceProvider` cmdlet as well as everything documented in the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs/tree/main/specification) repository and combined them to one big list of available API versions, as the `Get-AzResourceProvider` cmdlet alone does not return all api versions we'd expect.

Reviewing such a [failed test](https://github.com/Azure/ResourceModules/actions/runs/5865259551) today, I came to realize, the `Get-AzResourceProvider` cmdlet returns several additional API versions that are not yet documented anywhere for at least `Microsoft.NetApp/NetAppAccounts` (see below example).

The latest API version documented in
- [Bicep Types](https://github.com/Azure/bicep-types-az/tree/main/generated/netapp/microsoft.netapp)
- [Azure Template Reference](https://learn.microsoft.com/en-us/azure/templates/microsoft.netapp/2022-05-01/netappaccounts?pivots=deployment-language-bicep)
- [NetApp REST API documentation](https://learn.microsoft.com/en-us/rest/api/netapp/accounts/create-or-update?tabs=HTTP)
- [azure-rest-api-specs GitHub](https://github.com/Azure/azure-rest-api-specs/tree/main/specification/netapp/resource-manager/Microsoft.NetApp/stable)

Don't know anything beyond API version in 2022 (with the seemingly actual latest being `2022-11-01`m while the cmdlet believes it is `2023-03-01`.

While this is already an issue for us, I suspect that something might be slightly off with the script in general an Net-App may only be a lucky find.

### Issue script & Debug output

```PowerShell
((Get-AzResourceProvider -ProviderNamespace 'Microsoft.NetApp').ResourceTypes | Where-Object {
$_.ResourceTypeName -eq 'NetAppAccounts'
}).ApiVersions

# returns
# 2023-05-01-preview
# 2023-05-01
# 2023-03-01-preview
# 2023-03-01
# 2023-01-01-preview
# 2023-01-01
# 2022-11-01-preview
# 2022-11-01
# 2022-09-01
# 2022-07-01
# (...)
```

### Environment data

```PowerShell
PS > $PSVersionTable

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

### Module versions

```PowerShell
Whatever is installed as latest on the GitHub hosted runnners. [Documented](https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md#powershell-modules) is Az verion `9.3.0`.
```

### Error output

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied Get-AzResourceProvider query for Microsoft.NetApp/NetAppAccounts and compare its ApiVersions with the linked Bicep Types, Template Reference, REST documentation, and azure-rest-api-specs entries. Trace how the cmdlet obtains resource-provider versions and add coverage so returned versions match available API versions, including the reported 2023 entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, powershell
Domain
api, cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.