/// <summary>
 /// Convert from string to environment
 /// </summary>
 public static AzureEnvironment FromName(string name) {
     if (string.IsNullOrEmpty(name)) {
         return AzureEnvironment.AzureGlobalCloud;
     }
     var env = AzureEnvironment.FromName(name);
     if (env == null) {
         throw new ArgumentException(nameof(name));
     }
     return env;
 }
        public IAzure CreateAzureClient()
        {
            var environment = string.IsNullOrEmpty(AzureEnvironment) || AzureEnvironment == "AzureCloud"
                ? AzureEnvironmentEnum.AzureGlobalCloud
                : AzureEnvironmentEnum.FromName(AzureEnvironment) ??
                              throw new InvalidOperationException($"Unknown environment name {AzureEnvironment}");

            var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(ClientId,
                                                                                      Password, TenantId, environment
                                                                                      );

            // to ensure the Azure API uses the appropriate web proxy
            var client = new HttpClient(new HttpClientHandler {
                Proxy = WebRequest.DefaultWebProxy
            });

            return(Microsoft.Azure.Management.Fluent.Azure.Configure()
                   .WithHttpClient(client)
                   .Authenticate(credentials)
                   .WithSubscription(SubscriptionNumber));
        }