Skip to content

Commit

Permalink
[SQL] [LogReplay] Make Start-AzSqlInstanceDatabaseLogReplay synchrono…
Browse files Browse the repository at this point in the history
…us command (#13903)

* initial

* remove model

* Add AsJob Switch parameter so user can execute as background process as this is a long-running op

* change log updated

* regenerated help files

Co-authored-by: Milan Brkic <[email protected]>
  • Loading branch information
milanbrkic-ms and MDCS-sql authored Jan 12, 2021
1 parent b66c720 commit 04d572e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
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

0 comments on commit 04d572e

Please sign in to comment.