'Connect to Azure Government (US) using Azure.Management.Sql.SqlManagementClient

I have been trying to connect to azure gov Sql Server using Azure.Management.Sql.SqlManagementClient , and the credential I use uses cloud specific AzureEnvironment as shown below

 AzureCredentials azureCredentials = new AzureCredentialsFactory().FromServicePrincipal(
            ServicePrincipalName,
            cert,
            IsCertificateRollOverEnabled: true,
            aadTenantId,
            azureEnvironment)

I see that the AzureEnvironment in the doc does not have Azure Cloud specific sql suffix property like the keyvault/storage. I am suspecting this is the issue for I am getting the exception

    Microsoft.Rest.Azure.CloudException: The subscription 'xxx ' could not be found.
   at Microsoft.Azure.Management.Sql.ElasticPoolsOperations.ListByServerWithHttpMessagesAsync(String resourceGroupName, String serverName, Nullable`1 skip, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.Management.Sql.ElasticPoolsOperationsExtensions.ListByServerAsync(IElasticPoolsOperations operations, String resourceGroupName, String serverName, Nullable`1 skip, CancellationToken cancellationToken)

How can I connect to the Sql Server Azure US Gov using SqlManagementClient?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source