Confusing Error Message for Backup-AzApiManagement Command #26536
Labels
API Management
bug
This issue requires a change to an existing behavior in the product in order to be resolved.
customer-reported
Service Attention
This issue is responsible by Azure service team.
Description
When using the Backup-AzApiManagement command with only backup operation permissions, the command returns the error message 'Long running operation failed with status 'Forbidden'.
However, the backup operation actually succeeds. It appears this error occurs due to insufficient permissions to access the URL in the location header returned by the backup operation's REST call, specifically the permissions to get the operation results.
This error message is very misleading and makes it difficult to understand what permissions are actually required to execute the command successfully. Could you please update the error message to provide clearer guidance on the necessary permissions? thanks in advance!
Issue script & Debug output
PS /home/> Backup-AzApiManagement -ResourceGroupName $rg -Name $intApimName -StorageContext $storageContext -TargetContainerName $container -TargetBlobName $blob
DEBUG: 1+ >>>> Backup-AzApiManagement -ResourceGroupName $rg -Name $intApimName -StorageContext $storageContext -TargetContainerName $container -TargetBlobName $blob
DEBUG: 17+ function Get-ConciseViewPositionMessage >>>> {
DEBUG: 29+ >>>> $posmsg = ''
DEBUG: 30+ >>>> $headerWhitespace = ''
DEBUG: 31+ >>>> $offsetWhitespace = ''
DEBUG: 32+ >>>> $message = ''
DEBUG: 33+ >>>> $prefix = ''
DEBUG: 39+ if ( >>>> (($err.CategoryInfo.Category -eq 'ParserError' -and $err.Exception -is 'System.Management.Automation.ParentContainsErrorRecordException') -or $myinv.ScriptName -or $myinv.ScriptLineNumber -gt 1) -and$myinv.ScriptName -notmatch '.psm1$ ') {
DEBUG: 113+ if ( >>>> ! $err.ErrorDetails -or ! $err.ErrorDetails.Message) {
DEBUG: 114+ if ( >>>> $err.CategoryInfo.Category -eq 'ParserError' -and $err.Exception.Message.Contains("~$newline")) {
DEBUG: 118+ elseif ( >>>> $err.Exception) {
DEBUG: 119+ >>>> $message += $err.Exception.Message
DEBUG: 133+ if ( >>>> $myinv -and $myinv.ScriptName -or $err.CategoryInfo.Category -eq 'ParserError') {
DEBUG: 173+ >>>>$posmsg += "$ {errorColor}" + $message
DEBUG: 175+ >>>> $reason = 'Error'
DEBUG: 176+ if ( >>>> $err.Exception -and $err.Exception.WasThrownFromThrowStatement) {
DEBUG: 180+ elseif ( >>>> $myinv.MyCommand -and $myinv.MyCommand.Name -and (Get-Command -Name $myinv.MyCommand -ErrorAction Ignore))
DEBUG: 182+ >>>> $reason = $myinv.MyCommand
DEBUG: 201+ >>>> $errorMsg = 'Error'
DEBUG: 203+ >>>> "${errorColor}${reason}: ${posmsg}${resetcolor}"
DEBUG: 204+ >>>> }
DEBUG: 1+ & >>>> { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { >>>> Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { Set-StrictMode -Version 1; >>>> $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails >>>> }
DEBUG: 1+ & >>>> { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { >>>> Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { Set-StrictMode -Version 1; >>>> $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails >>>> }
Backup-AzApiManagement: Long running operation failed with status 'Forbidden'.
Environment data
NA
Module versions
PS /home/> Get-Module -Name Az.ApiManagement -ListAvailable
ModuleType Version PreRelease Name PSEdition ExportedCommands
Script 4.0.4 Az.ApiManagement Core,Desk {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiManagementProductToGroup, Add-AzApiManagementRegion…}
Error output
No response
The text was updated successfully, but these errors were encountered: