Skip to content

Implement cloud configuration support for Azure SDK for Rust #2898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 12, 2025

This PR implements comprehensive cloud configuration support for the Azure SDK for Rust, enabling services like Tables to work seamlessly across different Azure cloud environments including Azure Public Cloud, Azure China Cloud, Azure Germany Cloud, and Azure US Government Cloud.

Problem

Previously, the Azure SDK for Rust only supported Azure Public Cloud through hardcoded constants in authority_hosts and resource_manager_endpoint modules. Using the SDK with sovereign clouds required workarounds like custom TokenCredential implementations, creating friction for developers working in Azure China, Germany, or US Government clouds.

Solution

This implementation provides a comprehensive cloud configuration system that:

🏗️ Core Infrastructure

  • Cloud Configuration System: New azure_core::cloud module with CloudConfiguration struct containing authority hosts, resource manager endpoints, and service-specific audiences
  • Well-known Clouds: Pre-configured settings for Public, China, Germany, and US Government clouds accessible via configurations::azure_public_cloud(), etc.
  • Automatic Scope Derivation: CloudConfiguration::audience_to_scope() converts audience URIs to OAuth scopes

🔧 Enhanced Client Options

  • Cloud-Aware ClientOptions: Added cloud_config and audience fields to ClientOptions
  • Builder Methods: New with_cloud_config() and with_audience() for easy configuration
  • Smart Scope Resolution: get_auth_scope() method automatically derives correct OAuth scopes based on cloud and service

🔐 Identity Integration

  • Cloud-Aware Credentials: Enhanced TokenCredentialOptions with cloud configuration support
  • Convenience Constructors: Easy-to-use methods like ClientSecretCredential::new_for_china_cloud()
  • Automatic Authority Selection: Credentials automatically use correct authority host for the target cloud

Usage Examples

Simple credential creation for specific clouds:

// Create credential for China Cloud
let credential = ClientSecretCredential::new_for_china_cloud(
    tenant_id, client_id, secret
)?;

Service client configuration:

// Configure Tables client for China Cloud
let options = ClientOptions::default()
    .with_cloud_config(configurations::azure_china_cloud())
    .with_audience("https://storage.azure.com");

// Automatically get the correct OAuth scope
let scope = options.get_auth_scope(Some("tables"));
// Returns: "https://storage.azure.com/.default"

Complete integration example:

// This would be how a Tables service client uses cloud configuration
let tables_client = TablesClient::new_for_china_cloud(account_name, credential);
// Automatically uses correct endpoints and authentication scopes

Backward Compatibility

The old authority_hosts and resource_manager_endpoint modules are deprecated but remain functional, ensuring existing code continues to work while encouraging migration to the new cloud configuration system.

Benefits

  • Multi-Cloud Ready: Tables and other services can now work across all Azure clouds
  • Developer Experience: Consistent, easy-to-use API regardless of target cloud
  • Automatic Configuration: No more manual endpoint and scope management
  • Future-Proof: Extensible system ready for new Azure services and clouds

Testing

Added 75+ comprehensive tests covering all new functionality including cloud configuration creation, scope derivation, credential integration, and backward compatibility. All existing tests continue to pass.

Fixes #2439.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Support cloud configuration Implement cloud configuration support for Azure SDK for Rust Aug 12, 2025
@Copilot Copilot AI requested a review from RickWinter August 12, 2025 18:26
Copilot finished work on behalf of RickWinter August 12, 2025 18:26
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.

Support cloud configuration
2 participants