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

[BUG] Remove-TestResources.ps1 script fails to run #2299

Closed
Mohit-Chakraborty opened this issue Nov 17, 2021 · 8 comments
Closed

[BUG] Remove-TestResources.ps1 script fails to run #2299

Mohit-Chakraborty opened this issue Nov 17, 2021 · 8 comments
Labels
needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team.

Comments

@Mohit-Chakraborty
Copy link

Describe the bug
Remove-TestResources.ps1 script fails to run and cleanup test resources.

Expected behavior
The script runs successfully

Actual behavior (include Exception or Stack Trace)
The script fails to run because it calls the function Get-PurgeableGroupResources which calls the missing function Get-AzKeyVaultManagedHsm

To Reproduce

.\eng\common\TestResources\Remove-TestResources.ps1

Get-PurgeableGroupResources: C:\azure-sdk-for-net\eng\common\TestResources\Remove-TestResources.ps1:220
Line |
220 | $purgeableResources = Get-PurgeableGroupResources $ResourceGroupName
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'Get-AzKeyVaultManagedHsm' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name,
| or if a path was included, verify that the path is correct and try again.

@jsquire
Copy link
Member

jsquire commented Nov 17, 2021

//cc: @heaths

@heaths
Copy link
Member

heaths commented Nov 17, 2021

Please update your Az cmdlets: update-module az.

I can add a requirement, but it will only report an error earlier and should at least be more informative.

/cc @weshaggard @benbp

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 17, 2021
@heaths heaths transferred this issue from Azure/azure-sdk-for-net Nov 17, 2021
@weshaggard
Copy link
Member

The version requirement will at least give folks an idea of what needs to happen.

@heaths
Copy link
Member

heaths commented Nov 17, 2021

The more I think about this, I believe there was a reason why I might not have. @mikeharder didn't we have some conversation about this a while back before you made changes to try to load newer Az modules from outside the $env:PSModulePath? I could be crossing wires on something unrelated, though. Just want to double check.

Whatever the case, I wonder if we actually just want to take a dependency on an Az module that has dependencies on at least the versions of Az.* modules we want. While users can install individual Az.* modules directly - which is what the error might infer - it's best just to update them all.

@weshaggard
Copy link
Member

For DevOps we have some helpers for using the cached Az modules or installing as needed, see https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/scripts/Import-AzModules.ps1. If we need a newer version we should update the version in that script.

@heaths
Copy link
Member

heaths commented Nov 18, 2021

This runs as a separate task earlier in the pipeline, right? As long as modules can still be resolved via $env:PSModulePath then a #Requires ... statement should still work.

But updating only that script isn't enough. Humans don't run that script. So the #Requires still needs to be in the New-TestResources.ps1 script.

@heaths
Copy link
Member

heaths commented Nov 18, 2021

Currently we load Az 5.7.0, which depends on Az.KeyVault 3.4.1 which includes Get-AzKeyVaultManagedHsm. So I think we could safely add that as a dependency (min version). @Mohit-Chakraborty could you confirm that you had an older version. The below command will show all versions in case you already upgraded (alas, PSGet does not prune older versions because there's no ref-counting of older deps):

get-module -list Az.KeyVault

@kurtzeborn
Copy link
Member

Pretty sure this was addressed with this PR: #2306

Please reactivate if the issue continues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team.
Projects
None yet
Development

No branches or pull requests

5 participants