/// <summary> /// Verifys the server object to make sure the fields match what is provided /// </summary> /// <param name="server">The server object to validate</param> /// <param name="adminLogin">The expected administration login</param> /// <param name="location">The expected server location</param> /// <param name="version">The expected server verions</param> /// <param name="state">The expected state of the server</param> private static void VerifyServer(SqlDatabaseServerContext server, string adminLogin, string location, string version, string state) { Assert.AreEqual(adminLogin, server.AdministratorLogin, "Expecting server login to match."); Assert.AreEqual(location, server.Location, "Expecting matching location."); Assert.AreEqual(10, server.ServerName.Length, "Expecting a valid server name."); Assert.AreEqual(version, server.Version, "Server version doesn't match"); Assert.AreEqual(state, server.State, "Server state does not match"); }
private static void VerifyServer(SqlDatabaseServerContext server, string adminLogin, string location, string version, string state) { VerifyServer(server, adminLogin, location); Assert.AreEqual(version, server.Version, "Server version doesn't match"); Assert.AreEqual(state, server.State, "Server state does not match"); }
/// <summary> /// Creates a new server in the current subscription. /// </summary> /// <param name="adminLogin"> /// The administrator login name for the new server. /// </param> /// <param name="adminLoginPassword"> /// The administrator login password for the new server. /// </param> /// <param name="location"> /// The location in which to create the new server. /// </param> /// <returns>The context to the newly created server.</returns> internal SqlDatabaseServerContext NewAzureSqlDatabaseServerProcess( string adminLogin, string adminLoginPassword, string location, float? version) { // Do nothing if force is not specified and user cancelled the operation if (!Force.IsPresent && !ShouldProcess( Resources.NewAzureSqlDatabaseServerDescription, Resources.NewAzureSqlDatabaseServerWarning, Resources.ShouldProcessCaption)) { return null; } // Get the SQL management client for the current subscription SqlManagementClient sqlManagementClient = GetCurrentSqlClient(); // Set the retry policty to not retry attempts. sqlManagementClient.SetRetryPolicy(new RetryPolicy(new DefaultHttpErrorDetectionStrategy(), 0)); // Issue the create server request ServerCreateResponse response = sqlManagementClient.Servers.Create( new ServerCreateParameters() { Location = location, AdministratorUserName = adminLogin, AdministratorPassword = adminLoginPassword, Version = version.HasValue ? version.Value.ToString("F1") : null }); var newServer = sqlManagementClient.Servers.List().Servers.Where(s => s.Name == response.ServerName).FirstOrDefault(); if (newServer == null) { throw new ItemNotFoundException(string.Format( CultureInfo.InvariantCulture, Resources.CreateServerServerNotFound, response.ServerName)); } SqlDatabaseServerContext operationContext = new SqlDatabaseServerContext() { OperationStatus = Services.Constants.OperationSuccess, OperationDescription = CommandRuntime.ToString(), OperationId = response.RequestId, ServerName = newServer.Name, Location = location, AdministratorLogin = adminLogin, State = newServer.State, Version = newServer.Version }; return operationContext; }
/// <summary> /// Creates a new server in the current subscription. /// </summary> /// <param name="adminLogin"> /// The administrator login name for the new server. /// </param> /// <param name="adminLoginPassword"> /// The administrator login password for the new server. /// </param> /// <param name="location"> /// The location in which to create the new server. /// </param> /// <returns>The context to the newly created server.</returns> internal SqlDatabaseServerContext NewAzureSqlDatabaseServerProcess( string adminLogin, string adminLoginPassword, string location, float? version) { // Do nothing if force is not specified and user cancelled the operation if (!Force.IsPresent && !ShouldProcess( Resources.NewAzureSqlDatabaseServerDescription, Resources.NewAzureSqlDatabaseServerWarning, Resources.ShouldProcessCaption)) { return null; } // Get the SQL management client for the current subscription SqlManagementClient sqlManagementClient = GetCurrentSqlClient(); // Set the retry policty to not retry attempts. CloudExtensions.SetRetryPolicy<SqlManagementClient>( sqlManagementClient, new WindowsAzure.Common.TransientFaultHandling.RetryPolicy(new WindowsAzure.Common.TransientFaultHandling.DefaultHttpErrorDetectionStrategy(), 0)); // Issue the create server request ServerCreateResponse response = sqlManagementClient.Servers.Create( new ServerCreateParameters() { Location = location, AdministratorUserName = adminLogin, AdministratorPassword = adminLoginPassword, Version = version.HasValue ? version.Value.ToString("F1") : null }); SqlDatabaseServerContext operationContext = new SqlDatabaseServerContext() { OperationStatus = Services.Constants.OperationSuccess, OperationDescription = CommandRuntime.ToString(), OperationId = response.RequestId, ServerName = response.ServerName, Location = location, AdministratorLogin = adminLogin, }; return operationContext; }