Skip to content

[Batch] Upgrade azure-mgmt-batch from 17.3.0 to 19.0.0 - #34441

Open
Keyan Song (mskeyansong) wants to merge 9 commits into
Azure:devfrom
mskeyansong:keyan/batch-mgmt-sdk-update
Open

Keyan Song (mskeyansong) wants to merge 9 commits into
Azure:devfrom
mskeyansong:keyan/batch-mgmt-sdk-update

Conversation

@mskeyansong

@mskeyansong Keyan Song (mskeyansong) commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests Suppressions
⚠️ None ️✔️ 130/130 ️✔️ None
⚠️AzureCLI-BreakingChangeTest
⚠️batch
rule cmd_name rule_message suggest_message
⚠️ 1010 - ParaPropUpdate batch account create cmd batch account create update parameter public_network_access: updated property choices from ['Disabled', 'Enabled'] to ['Disabled', 'Enabled', 'SecuredByPerimeter']
⚠️ 1010 - ParaPropUpdate batch account set cmd batch account set update parameter public_network_access: updated property choices from ['Disabled', 'Enabled'] to ['Disabled', 'Enabled', 'SecuredByPerimeter']

Related command
az batch account
az batch application
az batch location
az batch private-endpoint-connection
az batch private-link-resource

Description
The Batch management commands use azure-mgmt-batch 17.3.0 (REST API 2024-02-01). This PR moves them to 19.0.0 (REST API 2025-06-01), the newest release on PyPI. It's the first step of moving az batch to the current Batch SDKs. The data plane (azure-batch 15.0.0b1) doesn't change here; it follows in a later PR. ADO: https://msazure.visualstudio.com/AzureBatch/_workitems/edit/40378677

Code changes:

  • Pin azure-mgmt-batch 19.0.0.
  • commands.py: 19.0.0 no longer has one module per operation group, so the commands load the operation classes from azure.mgmt.batch.operations.
  • custom.py: 17.3.0 filled in two values when they weren't given: the auto-storage authentication mode (StorageKeys) and the IP rule action (Allow). 19.0.0 doesn't, so the commands now send them explicitly and the requests stay the same. Public network access needs no change: since [Batch] az batch account identity assign, az batch account identity remove: Fix public network access being turned on #34452, the account updates set it themselves or leave it out.
  • custom.py: when the CLI passes None for account or application properties and none of them has a value, 19.0.0 still sends an empty "properties": {}; 17.3.0 left it out. az batch account create, az batch account set and az batch application set now pass only the properties that have a value. For example, az batch account create -n -g -l sends only {"location": ...} again. As with 17.3.0, az batch application set sends "allowUpdates": true for any non-empty --allow-updates value, including false; that older bug is tracked separately (ADO 40882829).
  • _params.py: 19.0.0 documents --filter, --maxresults and --account-name (private-endpoint-connection, private-link-resource) in a way the CLI help doesn't pick up, so these keep their current help.

What users see:

  • --public-network-access (az batch account create, az batch account set) also accepts SecuredByPerimeter, a value that REST API 2025-06-01 adds.
  • Output gains systemData (accounts, applications, application packages, private endpoint connections, private link resources) and tags (applications, application packages, private endpoint connections, private link resources); both are null unless the service returns them. az batch account network-profile network-rule add shows each IP rule's action (Allow), which the command already sent.
  • No option is added, removed or renamed. The requests compared with 17.3.0 have the same JSON bodies, or no body in either version (see the Testing Guide).

Tests:
The recordings used REST API 2024-02-01, so all 16 scenario tests are re-recorded (the data plane tests also call az batch account show and az batch account keys list). The network module's test_private_endpoint_connection_batch_account also creates a Batch account, so it's re-recorded too. Some tests needed changes because the service and the test environment changed since the last recordings, not because of the SDK:

  • Test storage accounts are StorageV2; general-purpose v1 accounts can no longer be created.
  • Pools use Ubuntu 22.04; the Ubuntu 18.04 node agent is gone.
  • test_batch_general_arm_cmd: checks that the two deleted accounts are gone instead of expecting an empty resource group (the tests were recorded in an existing group that holds other accounts), and checks the SKU list with Standard_D2s_v3, as Basic_A2 is no longer listed.
  • test_batch_application_cmd: an active package no longer returns a storageUrl (with either API version), so the test downloads the package blob from the account's storage account.
  • StorageSASReplacer also replaces a SAS signature that is the last query parameter.
  • The az batch pool usage-metrics list check also accepts The requested URI does not represent any resource, which the service returned while recording.
  • Rebased on [Batch] az batch: Fix duration options such as --max-wall-clock-time losing years and months #34450 (durations sent as typed) and {Batch} Compare request bodies of Batch requests in playback tests #34466 (request bodies checked in playback). Three recordings still had the duration values sent before [Batch] az batch: Fix duration options such as --max-wall-clock-time losing years and months #34450; a separate commit fixes them by hand: each request now holds what the CLI sends, and the responses after it what the service returned for the same values in dev's live recordings (PT0S; P1279DT12H30M5S for P3Y6M4DT12H30M5S). test_batch_jobs_and_tasks gives job set P3Y6M4DT12H30M5S again.
  • The empty properties change above alters one request in each of 11 recordings: the account create with only -n -g -l now sends {"location": "eastus2"} instead of {"location": "eastus2", "properties": {}}. A separate commit edits those 11 requests by hand (body and Content-Length only); the replies stay as recorded. A live check backs this (see the Testing Guide).
  • New unit tests check the bodies sent by az batch account create (a body containing only location, set by -l eastus; location, identity and tags with --mi-system-assigned true --tags a=b), az batch account set --tags (only tags), and az batch application set ({} with no options; "allowUpdates": true with --allow-updates true; the default version and display name with --default-version and --display-name).

Testing Guide

  • az batch account create -h, az batch account set -h: --public-network-access lists Disabled, Enabled, SecuredByPerimeter.
  • Help for all 128 az batch commands compared with dev: only az batch account create, az batch account set (the value above) and az batch application create (--parameters text from the SDK) changed.
  • Recorded Batch management PUT, PATCH and POST requests compared with dev's 17.3.0 recordings: 29 with the same JSON body, 15 with no body in either, none different.
  • 14 cases with a mocked management client, all the same as 17.3.0: az batch account create (-n -g -l only; --mi-system-assigned with --tags; --storage-account, --keyvault, --public-network-access Enabled and --tags), az batch account set (--tags; --storage-account with --tags), az batch account identity assign and remove (--system-assigned), az batch account network-profile set, az batch account network-profile network-rule add and delete, az batch application set (no options; --allow-updates true; --allow-updates false; --default-version with --display-name).
  • Live check on Nov 23 (subscription Batch-Portal-TIP): az batch account create -n -g -l in eastus2 (REST API 2025-06-01) sent {"location": "eastus2"}, reached Succeeded, and matched the 11 recorded creates on what was compared: the first reply (202, no body, a location header), the polling (202, then 200), the final account's fields and their types, and the defaults (publicNetworkAccess: Enabled, poolAllocationMode: BatchService, allowedAuthenticationModes: SharedKey, AAD). Generated IDs and timing weren't compared, and some response headers differ (request IDs, retry-after). In westus2, az batch account create --mi-system-assigned true --tags sent only location, tags and identity, and az batch account set --tags on an account with public network access Disabled sent only the tags and left it Disabled.
  • All 16 scenario tests and the network module's test were recorded live on Nov 16-17. After that, the duration values in three recordings and the account create request in 11 recordings were edited by hand (see Tests). In the recording subscription, eastus2 Batch accounts get *.bnvalidation.batch.azure.com endpoints.
  • azdev test batch (with the request body check), azdev style batch, and azdev linter with CI's options (changes against dev)

History Notes
[Batch] Upgrade azure-mgmt-batch from 17.3.0 to 19.0.0
[Batch] az batch account create, az batch account set: --public-network-access accepts SecuredByPerimeter


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 07:43
@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Nov 17, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Keyan Song (@mskeyansong)! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the Batch management SDK upgrade.

No open issues 🎉

What changed in this PR

Upgrades Azure CLI’s Batch management commands to azure-mgmt-batch 19.0.0 and REST API 2025-06-01, while leaving the data-plane SDK unchanged.

Changes:

  • Updates dependency declarations and operation-class lookup for the new SDK.
  • Makes previous SDK defaults explicit, preserves argument help, and enables SecuredByPerimeter as a public-network-access value.
  • Refreshes scenario tests, recordings, and SAS-signature sanitization for current service behavior.
File Description
src/​azure-cli/​requirements.py3.windows.txt Pins the Windows Batch management SDK to 19.0.0.
src/​azure-cli/​requirements.py3.Linux.txt Pins the Linux Batch management SDK to 19.0.0.
src/​azure-cli/​requirements.py3.Darwin.txt Pins the macOS Batch management SDK to 19.0.0.
src/​azure-cli/​pyproject.toml Updates the package’s Batch management dependency.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​tests/​latest/​test_batch_mgmt_commands.py Updates storage setup, account assertions, SKU checks, and package downloads.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​tests/​latest/​test_batch_data_plane_commands.py Updates Ubuntu images, duration input, and retired-API expectations.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​tests/​latest/​recordings/​test_batch_pool_osDisk_cmd.yaml Refreshes OS-disk scenario traffic for the management API upgrade.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​tests/​latest/​recordings/​test_batch_pool_enableAcceleratedNetworking_cmd.yaml Refreshes accelerated-networking scenario traffic.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​tests/​latest/​recording_processors.py Sanitizes SAS signatures regardless of query-parameter position.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​custom.py Explicitly supplies prior storage-authentication, public-access, and IP-rule defaults.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​commands.py Resolves operation classes through the SDK’s public operations module.
src/​azure-cli/​azure/​cli/​command_modules/​batch/​_params.py Preserves filter, page-size, and account-name help text.

Review effort: Balanced

@x-engineering-agent

Copy link
Copy Markdown
Contributor

Hi Keyan Song (@mskeyansong),
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@mskeyansong
Keyan Song (mskeyansong) marked this pull request as draft November 17, 2026 22:39
@mskeyansong

Copy link
Copy Markdown
Contributor Author

Moving this to draft while I review the Batch test coverage first. I'll mark it ready for review again after that.

azure-mgmt-batch 19.0.0 uses REST API 2025-06-01. azure-batch stays at 15.0.0b1.

- commands.py: load the management operation classes from azure.mgmt.batch.operations; 19.0.0 no longer has one
  module per operation group.
- custom.py: 17.3.0 filled in the auto-storage authentication mode, public network access and the IP rule action
  when they weren't given; send them explicitly so the requests stay the same.
- _params.py: keep the help of --filter, --maxresults and --account-name, which 19.0.0 no longer documents in a
  way the help can read.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Re-record the 16 scenario tests with azure-mgmt-batch 19.0.0 against today's service. Test changes needed because
the service and the test environment changed since the last recordings (not because of the SDK):
- Test storage accounts are StorageV2; general-purpose v1 accounts can no longer be created.
- Pools use Ubuntu 22.04; the Ubuntu 18.04 node agent is gone.
- test_batch_general_arm_cmd: check that the two deleted accounts are gone instead of expecting an empty group (the
  tests were recorded in an existing group that holds other accounts), and check the SKU list with Standard_D2s_v3,
  as Basic_A2 is no longer listed.
- test_batch_application_cmd: an active package no longer returns a storageUrl, so download the package blob from
  the account's storage account.
- StorageSASReplacer also replaces a signature that is the last query parameter.
- The usage metrics check also accepts the error that newer service builds return.
- test_batch_jobs_and_tasks gives the job's max wall-clock time in days (P1279DT12H30M5S, the value the service
  stored before): years and months in a duration are currently lost on the way to the service, a separate bug.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
test_private_endpoint_connection_batch_account (network module) creates a Batch account with
`az batch account create`, which now uses management API 2025-06-01. Recorded live with
azure-mgmt-batch 19.0.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Nov 16 recordings of test_batch_pool_upgradePolicy_cmd, test_batch_jobs_and_tasks and
test_batch_task_create_cmd predate Azure#34450, so they hold the values sent before it ("P" for PT0S,
P4DT12H30M05S for P3Y6M4DT12H30M5S), and the request body check from Azure#34466 rejects them.

Fixed by hand: each request now holds exactly what the CLI sends (checked against a local fake
endpoint), and the responses after it hold what the service returned for the same values in dev's
live recordings (PT0S; P1279DT12H30M5S for P3Y6M4DT12H30M5S). test_batch_jobs_and_tasks gives
`job set` P3Y6M4DT12H30M5S again instead of the same duration in days.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mskeyansong
Keyan Song (mskeyansong) marked this pull request as ready for review November 23, 2026 04:03
@mskeyansong
Keyan Song (mskeyansong) marked this pull request as draft November 23, 2026 06:53
@mskeyansong

Copy link
Copy Markdown
Contributor Author

Moving this back to draft for a small fix (ADO 40378677). We're upgrading the Batch management SDK while keeping the account commands working as before. With 19.0.0, az batch account create with only -n -g -l, az batch account create --mi-system-assigned --tags and az batch account set --tags send an empty properties object that 17.3.0 left out. We found it while rechecking the request bodies. Our fix: leave those settings out when they aren't given, as az batch account identity assign/remove already does, so those three requests match 17.3.0 again, and check it against the service. Is that OK? I'll mark it ready again after the live check and CI pass. Could you hold off on review until then?

…send without account properties

With azure-mgmt-batch 19.0.0, `account create -n -g -l`, `account create --mi-system-assigned
--tags` and `account set --tags` add an empty "properties" object, which 17.3.0 left out. The test
expects the 17.3.0 bodies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…az batch account set`

Pass auto-storage, public network access and encryption to the 19.0.0 models only when they're
given, as `az batch account identity assign/remove` already leave out public network access, so
the requests stay as they were with 17.3.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With azure-mgmt-batch 19.0.0, `application set` without options adds an empty "properties" object,
and `--allow-updates` goes out as a string. The test expects the 17.3.0 bodies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… `--allow-updates` as a boolean

As with azure-mgmt-batch 17.3.0, `--allow-updates` is sent as true for any value given.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ty "properties" fix

`az batch account create -n -g -l` sends {"location": ...} again, as with azure-mgmt-batch 17.3.0, instead of
{"location": ..., "properties": {}}. In the 11 recordings made with the old request, only that request's body and
Content-Length change; the replies stay as recorded. A live check (Nov 23, eastus2, REST API 2025-06-01) got the same
replies and the same account defaults as these recordings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mskeyansong
Keyan Song (mskeyansong) marked this pull request as ready for review November 24, 2026 05:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Batch az batch customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants