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

Get-AzDataProtectionJob returns limited number of backup jobs

Open tksh164 opened this issue 4 months ago • 1 comments

Description

A backup vault has 650+ backup jobs in Azure portal. But the Get-AzDataProtectionJob returns limited number of backup jobs.

In the debug output, I can see the nextLink property however it seems that the cmdlet is not using it.

Module: Az.DataProtection 3.0.1 (latest)

Issue script & Debug output

PS > $DebugPreference = 'Continue'
PS > Get-AzDataProtectionJob -VaultName $vaultName -ResourceGroupName $resourceGroupName | Measure-Object

... redacted ...

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.DataProtection/backupVaults/xxxx/backupJobs?api-version=2026-03-01

Headers:
x-ms-unique-id                : 3
x-ms-client-request-id        : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
CommandName                   : Az.DataProtection.internal\Get-AzDataProtectionJob
FullCommandName               : Get-AzDataProtectionJob_List
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v16.1.0,PSVersion/v7.6.4,Az.DataProtection/2.10.0

Body:
DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
X-Content-Type-Options        : nosniff
x-ms-operation-identifier     : tenantId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,objectId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/japaneast/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
x-ms-ratelimit-remaining-subscription-resource-requests: 1099
x-ms-request-id               : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
x-ms-correlation-request-id   : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
x-ms-routing-request-id       : JAPANEAST:20260727T014814Z:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Cache                       : CONFIG_NOCACHE
X-MSEdge-Ref                  : Ref A: 8E8CEB74F98148BFA0F4C24126AB6AD4 Ref B: TYO201100115025 Ref C: 2026-07-27T01:48:13Z
Date                          : Mon, 27 Jul 2026 01:48:14 GMT

Body:
{
  "value": [
    ... redacted ...

    {
      "properties": {
        "activityID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "subscriptionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "backupInstanceId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.DataProtection/backupVaults/xxxx/backupInstances/xxxx",
        "policyId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.DataProtection/backupVaults/xxxx/backupPolicies/xxxx",
        "dataSourceId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.Compute/disks/xxxx",
        "vaultName": "xxxx",
        "backupInstanceFriendlyName": "xxxx",
        "policyName": "xxxx",
        "sourceResourceGroup": "xxxx",
        "dataSourceSetName": "xxxx",
        "dataSourceName": "xxxx",
        "sourceDataStoreName": null,
        "sourceDataStoreType": null,
        "destinationDataStoreName": "OperationalTierStore",
        "progressEnabled": false,
        "etag": "W/\"datetime'2026-07-15T18%3A13%3A11.4610435Z'\"",
        "sourceSubscriptionID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "dataSourceLocation": "japaneast",
        "startTime": "2026-07-15T18:09:23.8420166Z",
        "endTime": "2026-07-15T18:13:11.2638245Z",
        "dataSourceType": "Microsoft.Compute/disks",
        "operationCategory": "Backup",
        "operation": "Backup",
        "status": "Completed",
        "restoreType": null,
        "isUserTriggered": false,
        "rehydrationPriority": null,
        "supportedActions": [],
        "duration": "00:03:47.4218079",
        "progressUrl": null,
        "isCrossRegionRestore": null,
        "errorDetails": null,
        "extendedInfo": null
      },
      "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.DataProtection/backupVaults/xxxx/backupJobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "type": "Microsoft.DataProtection/backupVaults/backupJobs"
    }
  ],
  "nextLink": "https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.DataProtection/backupVaults/xxxx/backupJobs?api-version=2026-03-01&$skiptoken=1!48!NWQ...ZmY4Mjll"
}
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: 10:48:14 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent:  Module: Az.DataProtection:3.0.1; CommandName: Get-AzDataProtectionJob; PSVersion: 7.6.4; IsSuccess: True; Duration: 00:00:01.0652125; SanitizeDuration: 00:00:00.0000327

Count             : 259
Average           : 
Sum               : 
Maximum           : 
Minimum           : 
StandardDeviation : 
Property          :

Environment data

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.6.4
PSEdition                      Core
GitCommitId                    7.6.4
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS > Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     5.5.1                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     3.0.1                 Az.DataProtection                   {Backup-AzDataProtectionBackupInstanceAdhoc, Edit-AzDataProtectionPolicyRetentionRuleClientO…

Error output

N/A

tksh164 avatar Jul 27 '26 02:07 tksh164

X Engineering Agent Bug analysis: Root cause analysis

Issue: Get-AzDataProtectionJob does not follow pagination — it returns only the first page (259 items) of results even when a nextLink is present in the API response, causing vaults with 260+ backup jobs to silently return incomplete data.

Root cause: The cmdlet makes a single GET request to the backupJobs endpoint and does not iterate using the nextLink URL returned in the response body. The debug output confirms nextLink is populated but never followed.

Affected command: Get-AzDataProtectionJob Module: Az.DataProtection (3.0.1) Repro: A backup vault with 260+ jobs — only 259 returned (one page).

Fix guidance:

  • In src/DataProtection/, locate the Get-AzDataProtectionJob implementation and ensure it uses the auto-paging (enumerating all pages via nextLink) so the cmdlet returns the full job list.
  • AutoRest-generated clients usually handle this automatically via GetAllAsync() / IPageable<T> — check whether the internal call uses the paging variant or the single-page variant.

Use this EXACT PR title: [DataProtection] fix pagination to return all backup jobs

PR title & description (azure-powershell)

Follow CONTRIBUTING.md. azure-powershell does not enforce a strict title gate — it requires a clear, informative title and a fully filled-out PR template.

Suggested PR title (clear & informative; [Module] prefix is the common convention):

[DataProtection] fix pagination to return all backup jobs

Required (per CONTRIBUTING.md):

  • Fill out the PR template completely — PRs are not reviewed without the completed checklist; do not delete it.
  • Link the issue — include Fixes #29899 in the description so the PR auto-closes it.
  • ChangeLog — add a bullet describing the fix under the ## Upcoming Release header of src/DataProtection/DataProtection/ChangeLog.md. Do not add a new version header.
  • Target branch — main.
  • Tests — add/adjust test coverage for the change. Tests must not contain hardcoded values (location, resource id, etc.) and must be re-recordable; do not skip existing tests.
  • Scope — keep the change limited to the affected module (src/DataProtection/).

X Engineering Agent · Fixer · react 👍 / 👎 to train the agent

x-engineering-agent avatar Jul 27 '26 02:07 x-engineering-agent