Azure SDK 4 .NET 是否支持 Azure gov?

Does Azure SDK 4 .NET support Azure gov?

尝试在 Azure Gov 中获取 Subscription 的操作,但 Azure ManagementClient 的默认 api 端点是全局端点:https://management.azure.com/

在我将 azure gov (https://management.usgovcloudapi.net/) 的端点指定给 ManagementClient 的构造方法后

例如 var managementClient = new ManagementClient(credentials, new Uri("https://management.usgovcloudapi.net/") 它 returns api 版本丢失.. 在我将 api-版本作为 uri 的后缀后,它 returns 找不到订阅 ID..

有人知道它也适用于 azure gov 吗?

请任何人或任何帮助。

Does Azure SDK 4 .NET support Azure gov?

是的,我们可以使用下面的SdkContext.AzureCredentialsFactory来选择Azure环境。以下是演示代码,您可以参考。

var tenantId = "tenant Id";
var secretKey = "secret Key ";
var clientId = "Application Id";
var subscriptionId = "subscription Id";
credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(clientId, secretKey, tenantId,AzureEnvironment.AzureUSGovernment);
var resourceManagementClient = new ResourceManagementClient(credentials)
            {
                SubscriptionId = subscriptionId 
            };