Repository navigation
[Batch] Upgrade azure-mgmt-batch from 17.3.0 to 19.0.0 - #34441
Keyan Song (mskeyansong) wants to merge 9 commits into
Conversation
|
Thank you for your contribution Keyan Song (@mskeyansong)! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
🟢 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
SecuredByPerimeteras 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
|
Hi Keyan Song (@mskeyansong), |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
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>
63244cb to
74e7d34
Compare
|
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, |
…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>
🤖 PR Validation —⚠️ Review suggested
Related command
az batch accountaz batch applicationaz batch locationaz batch private-endpoint-connectionaz batch private-link-resourceDescription
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 batchto 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/40378677Code changes:
commands.py: 19.0.0 no longer has one module per operation group, so the commands load the operation classes fromazure.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 passesNonefor 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 setandaz batch application setnow pass only the properties that have a value. For example,az batch account create -n -g -lsends only{"location": ...}again. As with 17.3.0,az batch application setsends"allowUpdates": truefor any non-empty--allow-updatesvalue, includingfalse; that older bug is tracked separately (ADO 40882829)._params.py: 19.0.0 documents--filter,--maxresultsand--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 acceptsSecuredByPerimeter, a value that REST API 2025-06-01 adds.systemData(accounts, applications, application packages, private endpoint connections, private link resources) andtags(applications, application packages, private endpoint connections, private link resources); both arenullunless the service returns them.az batch account network-profile network-rule addshows each IP rule'saction(Allow), which the command already sent.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 showandaz batch account keys list). The network module'stest_private_endpoint_connection_batch_accountalso 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:StorageV2; general-purpose v1 accounts can no longer be created.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 withStandard_D2s_v3, asBasic_A2is no longer listed.test_batch_application_cmd: an active package no longer returns astorageUrl(with either API version), so the test downloads the package blob from the account's storage account.StorageSASReplaceralso replaces a SAS signature that is the last query parameter.az batch pool usage-metrics listcheck also acceptsThe requested URI does not represent any resource, which the service returned while recording.az batch: Fix duration options such as--max-wall-clock-timelosing 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-timelosing 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 indev's live recordings (PT0S;P1279DT12H30M5SforP3Y6M4DT12H30M5S).test_batch_jobs_and_tasksgivesjob setP3Y6M4DT12H30M5Sagain.propertieschange above alters one request in each of 11 recordings: the account create with only-n -g -lnow 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).az batch account create(a body containing onlylocation, set by-l eastus;location,identityandtagswith--mi-system-assigned true --tags a=b),az batch account set --tags(onlytags), andaz batch application set({}with no options;"allowUpdates": truewith--allow-updates true; the default version and display name with--default-versionand--display-name).Testing Guide
az batch account create -h,az batch account set -h:--public-network-accesslistsDisabled, Enabled, SecuredByPerimeter.az batchcommands compared withdev: onlyaz batch account create,az batch account set(the value above) andaz batch application create(--parameterstext from the SDK) changed.dev's 17.3.0 recordings: 29 with the same JSON body, 15 with no body in either, none different.az batch account create(-n -g -lonly;--mi-system-assignedwith--tags;--storage-account,--keyvault,--public-network-access Enabledand--tags),az batch account set(--tags;--storage-accountwith--tags),az batch account identity assignandremove(--system-assigned),az batch account network-profile set,az batch account network-profile network-rule addanddelete,az batch application set(no options;--allow-updates true;--allow-updates false;--default-versionwith--display-name).az batch account create -n -g -lin eastus2 (REST API 2025-06-01) sent{"location": "eastus2"}, reachedSucceeded, and matched the 11 recorded creates on what was compared: the first reply (202, no body, alocationheader), 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 --tagssent only location, tags and identity, andaz batch account set --tagson an account with public network accessDisabledsent only the tags and left itDisabled.*.bnvalidation.batch.azure.comendpoints.azdev test batch(with the request body check),azdev style batch, andazdev linterwith CI's options (changes againstdev)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-accessacceptsSecuredByPerimeterThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.