尝试在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 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
};