Implement cloud configuration support for Azure SDK for Rust #2898
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.
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
andresource_manager_endpoint
modules. Using the SDK with sovereign clouds required workarounds like customTokenCredential
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
azure_core::cloud
module withCloudConfiguration
struct containing authority hosts, resource manager endpoints, and service-specific audiencesconfigurations::azure_public_cloud()
, etc.CloudConfiguration::audience_to_scope()
converts audience URIs to OAuth scopes🔧 Enhanced Client Options
cloud_config
andaudience
fields toClientOptions
with_cloud_config()
andwith_audience()
for easy configurationget_auth_scope()
method automatically derives correct OAuth scopes based on cloud and service🔐 Identity Integration
TokenCredentialOptions
with cloud configuration supportClientSecretCredential::new_for_china_cloud()
Usage Examples
Simple credential creation for specific clouds:
Service client configuration:
Complete integration example:
Backward Compatibility
The old
authority_hosts
andresource_manager_endpoint
modules are deprecated but remain functional, ensuring existing code continues to work while encouraging migration to the new cloud configuration system.Benefits
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.