Skip to content

Migrate archived MS Learn Java samples into azure-resourcemanager#49923

Open
weidongxu-microsoft wants to merge 11 commits into
Azure:mainfrom
weidongxu-microsoft:mgmt-migrate-archived-mslearn-samples
Open

Migrate archived MS Learn Java samples into azure-resourcemanager#49923
weidongxu-microsoft wants to merge 11 commits into
Azure:mainfrom
weidongxu-microsoft:mgmt-migrate-archived-mslearn-samples

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Member

Summary

Migrates the Java samples from four archived MS Learn pages into the azure-resourcemanager module under
src/samples/java, with recording tests under src/test/java/.../samples.

Archived source pages:

More detail to follow.

Mapping: MS Learn sample → file path

Paths are relative to sdk/resourcemanager/azure-resourcemanager/src/samples/java/com/azure/resourcemanager/.

Virtual machines

MS Learn sample File path
Create a virtual machine from a custom image compute/samples/CreateVirtualMachineUsingCustomImageFromVM.java
Create a virtual machine using specialized VHD from a snapshot compute/samples/CreateVirtualMachineUsingSpecializedDiskFromSnapshot.java
Create virtual machines in parallel in the same network compute/samples/ManageVirtualMachinesInParallel.java

Web apps

MS Learn sample File path
Create a web app and deploy from FTP or GitHub Skipped — MS Learn link is empty (./)
Create a web app and manage deployment slots appservice/samples/ManageWebAppSlots.java
Create a web app and configure a custom domain appservice/samples/ManageWebAppWithCustomDomain.java
Scale a web app with high availability across multiple regions appservice/samples/ScaleWebAppWithTrafficManager.java
Connect a web app to a storage account appservice/samples/ConnectWebAppToStorageAccount.java
Connect a web app to a SQL database appservice/samples/ConnectWebAppToSqlDatabase.java

SQL Database

MS Learn sample File path
Connect and query data from Azure SQL Database using JDBC Skipped — JDBC how-to tutorial, no management sample
Create and manage SQL databases sql/samples/ManageSqlDatabase.java
Manage SQL databases across multiple regions sql/samples/ManageSqlDatabasesAcrossRegions.java

Containers

MS Learn sample File path
Manage Azure Container Registries containerregistry/samples/ManageContainerRegistry.java
Manage Azure Container Service containerservice/samples/ManageKubernetesCluster.java (ACS retired → AKS)
Deploy an image from Azure Container Registry into a new Linux Web App appservice/samples/DeployImageFromAcrToLinuxWebApp.java

Tests

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).

weidongxu-microsoft and others added 11 commits July 24, 2026 11:00
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
@github-actions github-actions Bot added the Mgmt This issue is related to a management-plane library. label Jul 24, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@weidongxu-microsoft

Copy link
Copy Markdown
Member Author

/azp run java - pullrequest

@azure-pipelines

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

@weidongxu-microsoft

Copy link
Copy Markdown
Member Author

/azp run java - pullrequest

@azure-pipelines

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

@weidongxu-microsoft
weidongxu-microsoft marked this pull request as ready for review July 24, 2026 09:22
Copilot AI review requested due to automatic review settings July 24, 2026 09:22
@azure-pipelines

Copy link
Copy Markdown
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.

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.

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 SamplesTestBase to run the migrated samples under the resource-manager test-proxy framework.
  • Updated assets.json tag 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.

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

Labels

Mgmt This issue is related to a management-plane library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants