Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview apiVersion in generated ARM templates - do we need to filter versions? #834

Closed
jsandquist opened this issue Dec 5, 2023 · 4 comments · Fixed by #844
Closed

Preview apiVersion in generated ARM templates - do we need to filter versions? #834

jsandquist opened this issue Dec 5, 2023 · 4 comments · Fixed by #844
Assignees
Labels
area/powershell bug Something isn't working

Comments

@jsandquist
Copy link
Contributor

Describe the bug

AzOps versions 2.3.0 and 2.3.1

Since a day or two the 'pull' pipeline decided to update all apiVersions in all files more or less, some of the them with preview status. Something must have changed with regards to the output from Get-AzResourceProvider -ListAvailable?

Do we need to filter or sort the returned api versions perhaps?
Any other idea would be most welcome?

I found #422 and related #425 from two years back.

Below is an example for an ordinary resource group and what we see.

Steps to reproduce

  1. Connect-AzAccount ...
  2. (Get-AzResourceProvider -ListAvailable).ResourceTypes | Where-Object { $_.ResourceTypeName -eq "resourceGroups" } | Select-Object -ExpandProperty ApiVersions

to partly mimic the code at

$script:AzOpsResourceProvider = Get-AzResourceProvider -ListAvailable

and

$apiVersions = (($Script:AzOpsResourceProvider | Where-Object { $_.ProviderNamespace -eq $providerNamespace }).ResourceTypes | Where-Object { $_.ResourceTypeName -eq $resourceApiTypeName }).ApiVersions[0]

Screenshots

image

image

@daltondhcp
Copy link
Contributor

Thank you for reporting! It indeed looks like something's changed with the output from Get-AzResourceProvider cmdlet. We'll investigate.

@daltondhcp daltondhcp self-assigned this Dec 5, 2023
@daltondhcp
Copy link
Contributor

I've done some digging with the product group and it turns out this behavior has been around since day one 😄.
We've always just picked the first option in the list, which explains the current behavior. To make sure we're not missing out on resources with only preview API versions, we're planning to sort preview and GA API versions into separate arrays. This way, we'll only use the preview version if a GA version isn't available. What do you think about this approach?

@daltondhcp daltondhcp linked a pull request Jan 5, 2024 that will close this issue
5 tasks
@daltondhcp daltondhcp added bug Something isn't working area/powershell and removed triage labels Jan 5, 2024
@jsandquist
Copy link
Contributor Author

jsandquist commented Jan 5, 2024

Thanks for investigating! Seems like a really good approach. Personally, I was kind of confused as to why this was default behavior where the -Pre switch would fill the need to include preview versions (I thought).

@daltondhcp
Copy link
Contributor

Thanks for investigating! Seems like a really good approach. Personally, I was kind of confused as to why this was default behavior where the -Pre switch would fill the need to include preview versions (I thought).

That's a reasonable guess 😄. But here's an interesting bit: many Az.PowerShell cmdlets, include the -Pre parameter to 'consider preview API versions for the API call.' Essentially, this means that when you're running a cmdlet, it's equipped to handle the underlying REST call using these preview versions of the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/powershell bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants