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

问题描述 投票:-1回答:1

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

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

例如var managementClient = new ManagementClient(凭证,新的Uri(“https://management.usgovcloudapi.net/”)它返回api版本丢失..并且在我将api-version作为后缀添加到uri之后,它返回没有找到订阅ID。

任何人都知道它与天蓝色的政府合作吗?

请任何人或任何帮助。

azure-sdk-.net azure-gov
1个回答
0
投票

Azure SDK 4 .NET是否支持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 
            };
© www.soinside.com 2019 - 2024. All rights reserved.