-1

Try to get Subscription's operations within Azure Gov, but the default api endpoint for Azure ManagementClient is the global one: https://management.azure.com/,

After I specified the endpoint of azure gov ( https://management.usgovcloudapi.net/) to the ManagementClient's constructor method

e.g var managementClient = new ManagementClient(credentials, new Uri("https://management.usgovcloudapi.net/") it returns api version missing.. and after I put a api-version as a suffix to the uri, it returns no subscription id found..

any one know it works with azure gov as well?

please anyone or any help.

1 Answers1

0

Does Azure SDK 4 .NET support Azure gov?

Yes, we could use the following SdkContext.AzureCredentialsFactory to choose the Azure environment. The following is the demo code, you could refer to.

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 
            };
Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • What if I need to use a management certificates instead of AAD application to auth? – Peter Long Jul 17 '18 at 03:47
  • I use the ManagementClient class under Microsoft.WindowsAzure.Management namespace and get the operation logs by calling: await managementClient.Subscriptions.ListOperationsAsync(listOperationsParameters, cancellationToken); – Peter Long Jul 17 '18 at 03:54
  • It is recommanded that to use the [Azure fluent SDK](https://github.com/Azure/azure-libraries-for-net) to operate the Azure resource. – Tom Sun - MSFT Jul 17 '18 at 05:06
  • `Microsoft.WindowsAzure.Management` is not updated from 2015. Since all of azure resources are migrated to Azure portal. It is managed with Resource Management mode. It is recommanded that to use the Azure fluent SDK to operate the Azure resource. `SdkContext.AzureCredentialsFactory.FromServicePrincipal(String, X509Certificate2, String, AzureEnvironment)` – Tom Sun - MSFT Jul 17 '18 at 05:13