Get-AzureRmResourceGroup and Remove-AzureRmResourceGroup throws ArgumentException if resource does not exisit
Repro:
Get-AzureRmResourceGroup –Name 'CdvKeyVaultResourceGroup' –Location 'West US'
Get-AzureRmResourceGroup : Provided resource group does not exist.
At line:1 char:1
+ get-AzureRmResourceGroup –Name 'CdvKeyVaultResourceGroup' –Location ' ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmResourceGroup], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.GetAzureResourceGroupCommand
Expected: Get[/Remove]-AzureRmResourceGroup should return an empty result if resource group does not exist.
Lets fix this.
@TianoMS - Can you please take a look?
@hovsepm I checked the other cmdlets on how to handle similar cases, and the practice seems to be throwing exception.
Get-Process -Id 1234, throws ObjectNotFound exception. Get-AzureRmSubscription -Id "non-existing-Id", throws PSArgumentException.
I think I'll resolve this one as won't fix.
@TianoMS we should fix it in the other places as well. PSArgumentException/ArgumentException is wrong.
Fixed in 1.6.0
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @rthorn17