Migrate archived MS Learn Java samples into azure-resourcemanager#49923
Open
weidongxu-microsoft wants to merge 11 commits into
Open
Migrate archived MS Learn Java samples into azure-resourcemanager#49923weidongxu-microsoft wants to merge 11 commits into
weidongxu-microsoft wants to merge 11 commits into
Conversation
Move VM, web app, SQL database, and container samples from the archived MS Learn sample pages into azure-resourcemanager/src/samples. Add ARCHIVED_SAMPLES_MIGRATION.md to track sample name to file path mapping, Azure-Samples source repos, skipped samples, RBAC usage, and follow-up refinement notes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
ConnectWebAppToSqlDatabase: use Entra-only SQL with the web app's system-assigned managed identity as admin (no SQL login/password in app settings). ManageContainerRegistry: disable admin user and grant AcrPull role to a managed identity. SampleUtils: document/add a JDK 15+ Ed25519 alternative while keeping RSA 2048 as the Java 8 baseline default. DeployImageFromAcrToLinuxWebApp and ConnectWebAppToStorageAccount left on credentials due to App Service fluent-layer limitations (documented in ARCHIVED_SAMPLES_MIGRATION.md). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
…ord() ManageSqlDatabase and ManageSqlDatabasesAcrossRegions now create Microsoft Entra-only SQL Servers administered by a user-assigned managed identity, matching the pattern used in azure-resourcemanager-sql tests. With no remaining callers, the sample-only password() helper is removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
Add SamplesTestBase plus one test class per service (Compute, App Service, SQL, Container Registry, Container Service) under src/test, with one case per migrated sample, following the existing azure-resourcemanager and azure-resourcemanager-samples test conventions. Cases needing DNS/Traffic Manager/data-plane/cross-region calls are annotated @DoNotRecord(skipInPlayback = true). Written and compiled; not run (requires a live environment). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
Ran sample tests in RECORD mode against the live test subscription. 7 of 13 passed and were recorded; 6 are blocked by subscription policy/quota/region-capacity restrictions (documented in ARCHIVED_SAMPLES_MIGRATION.md). Adjusted regions to US_WEST3 for ManageSqlDatabase, ConnectWebAppToSqlDatabase (SQL server), ManageKubernetesCluster, and ManageSqlDatabasesAcrossRegions master to work around region capacity/SKU limits. No tests disabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
The VHD/unmanaged-disk approach required a shared-key storage account, which is blocked by the test subscription's disable-local-auth policy (and unmanaged VHD disks are legacy). Rewrote the sample to snapshot the VM's managed OS/data disks, create new managed disks from the snapshots, and attach them to a new VM - still demonstrating specialized disks, without any storage account. Renamed to CreateVirtualMachineUsingSpecializedDiskFromSnapshot and recorded successfully in US_WEST2. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
… quota The sample creates 3 web apps/plans across 3 regions successfully and only fails at the final scale-up step (doubling a plan to 2 instances), which the test subscription's App Service 'Total VMs' quota of 1 rejects. Marked @disabled with the constraint documented; sample left unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
Only 2 regions (US_WEST3, US_EAST2) accepted new SQL server creation in the test subscription; the rest returned 'not accepting creation of new SQL Database servers'. Reduced the sample from 2 secondaries to 1 so it still demonstrates cross-region geo-replication and passes live. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
Record four previously-unrecorded sample tests and finalize @DoNotRecord audit: - ManageContainerRegistry, ConnectWebAppToStorageAccount, DeployImageFromAcrToLinuxWebApp recorded on a personal subscription (test-sub policy/quota blocks them); Japan East for the two App Service samples. - ManageSqlDatabasesAcrossRegions recorded on the shared test subscription. - Make the AcrPull role-assignment name deterministic via SampleUtils.randomUuid so it replays in playback (raw UUID.randomUUID broke request matching). - Keep testManageWebAppWithCustomDomain @DoNotRecord (DNS) and testScaleWebAppWithTrafficManager @disabled (needs multi-region App Service quota). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
Tracking/notes doc kept locally only; its content goes into the PR description instead of the repo. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4727c5a4-1b1d-4c1d-af70-7b9e7f83f806
|
Azure Pipelines: Successfully started running 1 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
/azp run java - pullrequest |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Member
Author
|
/azp run java - pullrequest |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
weidongxu-microsoft
marked this pull request as ready for review
July 24, 2026 09:22
weidongxu-microsoft
requested review from
a team,
ArthurMa1978,
XiaofeiCao and
haolingdong-msft
as code owners
July 24, 2026 09:22
|
Azure Pipelines: Successfully started running 1 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates a set of archived Microsoft Learn Java management samples into the sdk/resourcemanager/azure-resourcemanager module, adding corresponding JUnit tests intended to run under test-proxy playback with updated assets tag.
Changes:
- Added new Resource Manager sample implementations across compute, app service, SQL, container registry, and AKS.
- Added sample test suites and a shared
SamplesTestBaseto run the migrated samples under the resource-manager test-proxy framework. - Updated
assets.jsontag to point at the refreshed recordings package for playback.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/samples/SqlSampleTests.java | Adds playback tests for the migrated SQL samples. |
| sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/samples/SamplesTestBase.java | Introduces shared test-proxy base wiring (pipeline, sanitizers, ARM client init) for sample tests. |
| sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/samples/ContainerServiceSampleTests.java | Adds playback test coverage for the AKS sample. |
| sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/samples/ContainerRegistrySampleTests.java | Adds playback test coverage for the ACR sample. |
| sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/samples/ComputeSampleTests.java | Adds playback tests for the migrated compute samples. |
| sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/samples/AppServiceSampleTests.java | Adds playback tests for the migrated App Service samples, including skip/disabled annotations. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/sql/samples/package-info.java | Package documentation for SQL samples. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/sql/samples/ManageSqlDatabasesAcrossRegions.java | New SQL sample demonstrating cross-region replica setup and firewall rules. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/sql/samples/ManageSqlDatabase.java | New SQL sample demonstrating DB CRUD + SKU update + firewall rule management. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/samples/SampleUtils.java | Adds shared sample helpers (stable random names/UUIDs; SSH key generation). |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/samples/package-info.java | Package documentation for shared sample utilities. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/containerservice/samples/package-info.java | Package documentation for AKS samples. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/containerservice/samples/ManageKubernetesCluster.java | New AKS sample replacing retired ACS content. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/containerregistry/samples/package-info.java | Package documentation for ACR samples. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/containerregistry/samples/ManageContainerRegistry.java | New ACR sample using AcrPull role assignment to a managed identity. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/compute/samples/package-info.java | Package documentation for compute samples. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/compute/samples/ManageVirtualMachinesInParallel.java | New compute sample creating multiple VMs in parallel in a shared VNet. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/compute/samples/CreateVirtualMachineUsingSpecializedDiskFromSnapshot.java | New compute sample snapshotting specialized disks and rehydrating a VM. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/compute/samples/CreateVirtualMachineUsingCustomImageFromVM.java | New compute sample capturing a generalized image and creating a VM from it. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/ScaleWebAppWithTrafficManager.java | New App Service HA sample using Traffic Manager + scale-up. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/package-info.java | Package documentation for App Service samples. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/ManageWebAppWithCustomDomain.java | New App Service sample purchasing and binding an Azure-managed domain. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/ManageWebAppSlots.java | New App Service sample managing deployment slots and swapping. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/DeployImageFromAcrToLinuxWebApp.java | New App Service sample deploying a private ACR image to a Linux web app. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/ConnectWebAppToStorageAccount.java | New App Service sample wiring storage connection string into app settings. |
| sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/appservice/samples/ConnectWebAppToSqlDatabase.java | New App Service sample wiring passwordless SQL connectivity using managed identity. |
| sdk/resourcemanager/azure-resourcemanager/assets.json | Updates the assets tag to the new recordings set for these sample tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the Java samples from four archived MS Learn pages into the
azure-resourcemanagermodule undersrc/samples/java, with recording tests undersrc/test/java/.../samples.Archived source pages:
Mapping: MS Learn sample → file path
Paths are relative to
sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/.Virtual machines
compute/samples/CreateVirtualMachineUsingCustomImageFromVM.javacompute/samples/CreateVirtualMachineUsingSpecializedDiskFromSnapshot.javacompute/samples/ManageVirtualMachinesInParallel.javaWeb apps
./)appservice/samples/ManageWebAppSlots.javaappservice/samples/ManageWebAppWithCustomDomain.javaappservice/samples/ScaleWebAppWithTrafficManager.javaappservice/samples/ConnectWebAppToStorageAccount.javaappservice/samples/ConnectWebAppToSqlDatabase.javaSQL Database
sql/samples/ManageSqlDatabase.javasql/samples/ManageSqlDatabasesAcrossRegions.javaContainers
containerregistry/samples/ManageContainerRegistry.javacontainerservice/samples/ManageKubernetesCluster.java(ACS retired → AKS)appservice/samples/DeployImageFromAcrToLinuxWebApp.javaTests
11 of 13 sample tests are recorded and replay in playback. Two are intentionally not recorded:
testManageWebAppWithCustomDomain—@DoNotRecord(custom-domain DNS cannot be recorded).testScaleWebAppWithTrafficManager—@Disabled(needs App Service "Total VMs" quota across 3 regions).