/// <summary> /// Removes an existing server in the current subscription. /// </summary> /// <param name="serverName">The name of the server to remove.</param> /// <returns>The context to this operation.</returns> internal SqlDatabaseServerOperationContext RemoveAzureSqlDatabaseServerProcess(string serverName) { // Do nothing if force is not specified and user cancelled the operation if (!Force.IsPresent && !ShouldProcess( string.Format(CultureInfo.InvariantCulture, Resources.RemoveAzureSqlDatabaseServerDescription, serverName), string.Format(CultureInfo.InvariantCulture, Resources.RemoveAzureSqlDatabaseServerWarning, serverName), Resources.ShouldProcessCaption)) { return null; } // Get the SQL management client for the current subscription SqlManagementClient sqlManagementClient = GetCurrentSqlClient(); // Issue the delete server request OperationResponse response = sqlManagementClient.Servers.Delete(serverName); SqlDatabaseServerOperationContext operationContext = new SqlDatabaseServerOperationContext() { OperationStatus = Services.Constants.OperationSuccess, OperationDescription = CommandRuntime.ToString(), OperationId = response.RequestId, ServerName = serverName, }; return operationContext; }
/// <summary> /// Resets the administrator password for an existing server in the /// current subscription. /// </summary> /// <param name="serverName"> /// The name of the server for which to reset the password. /// </param> /// <param name="newPassword"> /// The new password for the server. /// </param> /// <returns>The context to this operation.</returns> internal SqlDatabaseServerOperationContext ResetAzureSqlDatabaseServerAdminPasswordProcess(string serverName, string newPassword) { // Do nothing if force is not specified and user cancelled the operation if (!Force.IsPresent && !ShouldProcess( string.Format(CultureInfo.InvariantCulture, Resources.SetAzureSqlDatabaseServerAdminPasswordDescription, serverName), string.Format(CultureInfo.InvariantCulture, Resources.SetAzureSqlDatabaseServerAdminPasswordWarning, serverName), Resources.ShouldProcessCaption)) { return null; } // Get the SQL management client for the current subscription SqlManagementClient sqlManagementClient = GetCurrentSqlClient(); // Issue the change admin password request AzureOperationResponse response = sqlManagementClient.Servers.ChangeAdministratorPassword( serverName, new ServerChangeAdministratorPasswordParameters() { NewPassword = newPassword }); SqlDatabaseServerOperationContext operationContext = new SqlDatabaseServerOperationContext() { OperationStatus = Services.Constants.OperationSuccess, OperationDescription = CommandRuntime.ToString(), OperationId = response.RequestId, ServerName = serverName, }; return operationContext; }