Skip to content

Add the cloudSetting option for ARM Modular SDK#3233

Merged
MaryGao merged 35 commits intoAzure:mainfrom
MaryGao:support-multi-cloud-modular
Jul 16, 2025
Merged

Add the cloudSetting option for ARM Modular SDK#3233
MaryGao merged 35 commits intoAzure:mainfrom
MaryGao:support-multi-cloud-modular

Conversation

@MaryGao
Copy link
Member

@MaryGao MaryGao commented Jun 3, 2025

fixes #3188

This PR adds multi-cloud support for MPG, enabling generated clients to connect to different Azure cloud environments.

Changes made:

  • Added AzureClouds fixed enum with values for different cloud environments (Public, China, US Government)
  • Updated the client generator to accept an cloudSetting parameter in client options
  • Modified endpoint setup logic to use the cloud parameter when determining the endpoint URL

Now users can specify which Azure cloud environment to connect to when creating a client:

import { NetworkCloud, AzureClouds } from "@azure/arm-networkcloud";
import { DefaultAzureCredential } from "@azure/identity";

// Create a client for the Azure China Cloud environment
const client = new NetworkCloud(
  new DefaultAzureCredential(),
  "your-subscription-id",
  { 
    cloudSetting: AzureClouds.AzureChinaCloud 
  }
);

@MaryGao MaryGao changed the title Add the cloud setting option for ARM modular SDK Add the cloud setting option for ARM Modular SDK Jun 3, 2025
@MaryGao MaryGao marked this pull request as ready for review June 23, 2025 06:13
@MaryGao MaryGao requested review from joheredi and qiaozha as code owners June 23, 2025 06:13
@MaryGao MaryGao requested review from xiangyan99 and xirzec June 23, 2025 07:45
@MaryGao MaryGao force-pushed the support-multi-cloud-modular branch from 7c43cac to ed48054 Compare June 23, 2025 08:41
@lirenhe lirenhe requested a review from Copilot June 23, 2025 09:00

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@xiangyan99 xiangyan99 left a comment

Choose a reason for hiding this comment

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

LGTM

@MaryGao MaryGao requested a review from lirenhe June 24, 2025 05:56
@MaryGao MaryGao requested a review from Copilot July 15, 2025 14:34
Copy link
Contributor

Copilot AI left a comment

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 adds multi-cloud support for Azure ARM Modular SDK clients, enabling them to connect to different Azure cloud environments (Public, China, US Government). The implementation includes a new AzureClouds enum and cloud-specific endpoint resolution logic.

Key changes:

  • Added AzureClouds enum with predefined cloud environment values and endpoint mapping function
  • Updated client options interface to include optional cloudSetting parameter for ARM clients
  • Modified endpoint resolution logic to use cloud-specific endpoints when cloudSetting is provided

Reviewed Changes

Copilot reviewed 8 out of 32 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/typespec-ts/static/static-helpers/cloudSettingHelpers.ts New helper file defining AzureClouds enum and getArmEndpoint function for cloud endpoint resolution
packages/typespec-ts/src/modular/static-helpers-metadata.ts Added metadata definitions for cloud setting helpers
packages/typespec-ts/src/modular/helpers/clientHelpers.ts Updated endpoint parameter building to support cloud setting fallback for ARM clients
packages/typespec-ts/src/modular/buildRootIndex.ts Added export logic for AzureClouds enum and refactored export helper functions
packages/typespec-ts/src/modular/buildClientContext.ts Added cloudSetting property to ARM client options and parameter name conflict detection
packages/typespec-ts/src/lib.ts Added new diagnostic for parameter name conflicts
packages/typespec-ts/src/index.ts Registered CloudSettingHelpers in the static helpers collection
packages/typespec-ts/src/framework/load-static-helpers.ts Extended framework to support enum declarations in static helpers

@MaryGao MaryGao changed the title Add the cloud setting option for ARM Modular SDK Add the cloudSetting option for ARM Modular SDK Jul 15, 2025
Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

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

Small comments on the generated code, only one that I feel strongly about is fixing the error message.

MaryGao and others added 3 commits July 16, 2025 10:44
…ted/typespec-ts/sdk/test/arm-test/src/static-helpers/cloudSettingHelpers.ts

Co-authored-by: Jeff Fisher <xirzec@xirzec.com>
…ted/typespec-ts/sdk/test/arm-test/src/static-helpers/cloudSettingHelpers.ts

Co-authored-by: Jeff Fisher <xirzec@xirzec.com>
@MaryGao MaryGao enabled auto-merge (squash) July 16, 2025 03:10
@MaryGao MaryGao merged commit 9f296cf into Azure:main Jul 16, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-cloud support for MPG

7 participants