public bool AddAccount(string accountName, string clientid, string clientsecretkey, string tenantid, string subscriptionid) { try { AzureProfile azure = new AzureProfile(); azure.ClientId = clientid; azure.ClientSecretKey = clientsecretkey; azure.TenantId = tenantid; azure.SubscriptionId = subscriptionid; var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(clientid, clientsecretkey, tenantid, AzureEnvironment.AzureGlobalCloud); var response = Azure.Authenticate(credentials).WithSubscription(subscriptionid); if (response.ResourceGroups.List().Count() > 0) { if (SqlHelper.AddNewAccount("Azure", accountName) && SqlHelper.AddAzureAccountDetails(azure, accountName)) { return(true); } return(false); } return(false); } catch (Exception e) { return(false); } }