azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

ErrorAction does not work with Get-AzureRmResource

Open rajaprad opened this issue 10 years ago • 8 comments

I am trying to suppress error from Get-AzureRmResource however it is not taking effect with ErrorActionPreference.

Get-AzureRmResource -ResourceName "hiddenforsecurity" -ResourceType "Microsoft.Web/serverFarms" -ResourceGroupName "Howareyou" -ErrorAction SilentlyContinue Get-AzureRmResource : ResourceNotFound : The Resource 'Microsoft.Web/serverFarms/hiddenforsecurity' under resource group 'Howareyou' was not found. At line:1 char:8

  • $new = Get-AzureRmResource -ResourceName hiddenforsecurity -ResourceType "Microsof ...
  • - CategoryInfo          : CloseError: (:) [Get-AzureRmResource], ErrorResponseMessageException
    - FullyQualifiedErrorId : ResourceNotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet
    
    

Thanks, Pradebban Raja

rajaprad avatar Dec 08 '15 15:12 rajaprad

Looks to be the same issue as #1450, #1451, #1452

graemechristie avatar Dec 11 '15 07:12 graemechristie

Lets look into supporting this.

ravbhatnagar avatar Feb 11 '16 19:02 ravbhatnagar

@markcowl - I believe we need to consistently support this across cmdlets. It is not specific to ARM. Hence removing the ARM label and assigning it to your team. Please let me know if you feel otherwise.

ravbhatnagar avatar May 18 '16 23:05 ravbhatnagar

@ravbhatnagar See https://github.com/Azure/azure-powershell/pull/2736/files This is resolved for cmdlets that use the AzurePSCmdlet override of ProcessRecord. Reassigning to you so you cna verify this is the case for ResourceManager cmdlets.

markcowl avatar Aug 08 '16 19:08 markcowl

Any progress on this issue? I'm using Get-AzureRmResource cmdlet to check if AppInsights exists or not. Used $erroractionpreference='silentlycontinue' to suppress the error and it works perfectly on my machine. But when ran as a release definition task on VSTS hosted agent the erroractionpreference doesn't work and it is simply terminating the program. Please provide some work around for this.

sarath-rachuri avatar Dec 20 '17 05:12 sarath-rachuri

Hi guys, I have the same error. Also, when I create a new db, there is a question that I must respond to continue.

error

How can I skip programmatically this prompt? Force is enough? Thanks

erossini avatar Apr 23 '18 11:04 erossini

I believe this will be resolved in PR https://github.com/Azure/azure-powershell/pull/6008

cormacpayne avatar Apr 27 '18 00:04 cormacpayne

The fix for this should be available on May 7th in version 6.0.0 of AzureRM (version 6.0.0 of AzureRM.Resources). Please re-open this issue if the problem persists.

cormacpayne avatar May 02 '18 20:05 cormacpayne