/// <summary> /// Creates a new sql database. /// </summary> /// <param name="databaseName">The name for the new database</param> /// <param name="databaseMaxSize">The maximum size of the new database</param> /// <param name="databaseCollation">The collation for the new database</param> /// <param name="databaseEdition">The edition for the new database</param> /// <returns>The newly created Sql Database</returns> public Database CreateNewDatabase( string databaseName, int?databaseMaxSize, string databaseCollation, DatabaseEdition databaseEdition) { this.clientRequestId = SqlDatabaseManagementHelper.GenerateClientTracingId(); ISqlDatabaseManagement channel = GetManagementChannel(); SqlDatabaseInput input = new SqlDatabaseInput(); input.Name = databaseName; input.CollationName = databaseCollation ?? string.Empty; //determine the edition if (databaseEdition != DatabaseEdition.None) { input.Edition = databaseEdition.ToString(); } else { input.Edition = string.Empty; } //determine the maximum size if (databaseMaxSize.HasValue) { input.MaxSizeGB = databaseMaxSize.ToString(); } //create a new database on the server SqlDatabaseResponse response = channel.EndNewDatabase( channel.BeginNewDatabase(this.subscriptionId, this.serverName, input, null, null)); Database database = CreateDatabaseFromResponse(response); return(database); }