Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] [LogReplay] Make Start-AzSqlInstanceDatabaseLogReplay synchronous command #13903

Merged
merged 6 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Made `Start-AzSqlInstanceDatabaseLogReplay` cmdlet synchronous, added -AsJob flag

## Version 2.14.0
* Fixed parameter description for `InstanceFailoverGroup` command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public class StartAzureSqlInstanceDatabaseLogReplay : AzureSqlManagedDatabaseLog
[PSArgumentCompleter("SQL_Latin1_General_CP1_CI_AS", "Latin1_General_100_CS_AS_SC")]
public string Collation { get; set; }

/// <summary>
/// Gets or sets whether or not to run this cmdlet in the background as a job
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

/// <summary>
/// Get the entities from the service
/// </summary>
Expand Down Expand Up @@ -128,8 +134,7 @@ protected override AzureSqlManagedDatabaseModel ApplyUserInputToModel(AzureSqlMa

protected override AzureSqlManagedDatabaseModel PersistChanges(AzureSqlManagedDatabaseModel entity)
{
ModelAdapter.StartManagedDatabaseLogReplay(entity);
return entity;
return ModelAdapter.StartManagedDatabaseLogReplay(entity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public string GetDeletedManagedDatabaseResourceId(string resourceGroupName, stri
/// Start the managed database log replay
/// </summary>
/// <param name="parameters">The parameters for log replay</param>
public void StartManagedDatabaseLogReplay(AzureSqlManagedDatabaseModel parameters)
public AzureSqlManagedDatabaseModel StartManagedDatabaseLogReplay(AzureSqlManagedDatabaseModel parameters)
{
var model = new Management.Sql.Models.ManagedDatabase()
{
Expand All @@ -194,7 +194,8 @@ public void StartManagedDatabaseLogReplay(AzureSqlManagedDatabaseModel parameter
StorageContainerUri = parameters.StorageContainerUri,
StorageContainerSasToken = parameters.StorageContainerSasToken
};
Communicator.StartLogReplay(parameters.ResourceGroupName, parameters.ManagedInstanceName, parameters.Name, model);
var response = Communicator.StartLogReplay(parameters.ResourceGroupName, parameters.ManagedInstanceName, parameters.Name, model);
return CreateManagedDatabaseModelFromResponse(parameters.ResourceGroupName, parameters.ManagedInstanceName, response);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ public void CompleteLogReplay(string resourceGroupName, string managedInstanceNa
/// <param name="managedInstanceName">The name of the Azure SQL Managed Instance</param>
/// <param name="databaseName">The name of the Azure SQL Managed database</param>
/// <param name="model">Model describing the managed database log replay request</param>
public Task StartLogReplay(string resourceGroupName, string managedInstanceName, string databaseName, Management.Sql.Models.ManagedDatabase model)
public Management.Sql.Models.ManagedDatabase StartLogReplay(string resourceGroupName, string managedInstanceName, string databaseName, Management.Sql.Models.ManagedDatabase model)
{
return GetCurrentSqlClient().ManagedDatabases.CreateOrUpdateAsync(
return GetCurrentSqlClient().ManagedDatabases.CreateOrUpdate(
resourceGroupName,
managedInstanceName,
databaseName,
Expand Down
19 changes: 17 additions & 2 deletions src/Sql/Sql/help/Start-AzSqlInstanceDatabaseLogReplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Starts a Log Replay service with the given parameters.
### LogReplayInstanceDatabaseFromInputParameters (Default)
```
Start-AzSqlInstanceDatabaseLogReplay -StorageContainerUri <String> -StorageContainerSasToken <String>
[-AutoCompleteRestore] [-LastBackupName <String>] [-Collation <String>] [-Name] <String>
[-AutoCompleteRestore] [-LastBackupName <String>] [-Collation <String>] [-AsJob] [-Name] <String>
[-InstanceName] <String> [-ResourceGroupName] <String> [-PassThru] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

### LogReplayInstanceDatabaseFromAzureSqlManagedDatabaseModelInstanceDefinition
```
Start-AzSqlInstanceDatabaseLogReplay -StorageContainerUri <String> -StorageContainerSasToken <String>
[-AutoCompleteRestore] [-LastBackupName <String>] [-Collation <String>] [-PassThru]
[-AutoCompleteRestore] [-LastBackupName <String>] [-Collation <String>] [-AsJob] [-PassThru]
[-InputObject] <AzureSqlManagedDatabaseModel> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
Expand Down Expand Up @@ -54,6 +54,21 @@ This command will create new managed database and will start restoring backups f

## PARAMETERS

### -AsJob
Run cmdlet in the background

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -AutoCompleteRestore
The indicator whether or not to auto-complete restore upon completion.

Expand Down