Skip to content

Commit

Permalink
adding SQL DB migration cmdlets to AZ.DataMigration (#17406)
Browse files Browse the repository at this point in the history
* adding option to launch a new console for running perfDatCollection

* nit error

* Adding Sql DB cmdlets

* updating examples , documentation and adding testcases for SQL Db

* unit test cases

* update doc/example for sql db

* Adding message to distinguish between v1 and v2 cmdlets
updating SQL VM documentation regarding scope.

* adding description for scope parameter of dql VM

* Adding example for delete sql db cmdlet (with optional force parameter)

* Adding test for delete/remove sql db

* removing new console from perf

* removing creds from test recordings

* hiding credentials from env.json

* Remove MigrationoperationId and Provisioning error from New-AzDataMigrationSqlDb
Make MigrationoperationId "required" for Stop-AzDataMigrationToSqlDb

* description changes
removing migrationoperatinid and provisioning error from new sqlMI and new SqlVM migrations
referring to swagger from the PR

* Revert "description changes"

This reverts commit 5ea6516.

* Revert "Revert "description changes""

This reverts commit 8d564fc.

* referring to the main branch

* modifying examples and tests to include secure strings

Co-authored-by: Vasundhra Manhas <vmanhas@microsoft.com>
  • Loading branch information
vasundhraManhas and Vasundhra Manhas authored Apr 12, 2022
1 parent f504061 commit dae72ea
Showing 62 changed files with 2,798 additions and 263 deletions.
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.DataMigration.private.dll'
FormatsToProcess = './Az.DataMigration.format.ps1xml'
FunctionsToExport = 'Get-AzDataMigrationAssessment', 'Get-AzDataMigrationPerformanceDataCollection', 'Get-AzDataMigrationSkuRecommendation', 'Get-AzDataMigrationSqlService', 'Get-AzDataMigrationSqlServiceAuthKey', 'Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric', 'Get-AzDataMigrationSqlServiceMigration', 'Get-AzDataMigrationToSqlManagedInstance', 'Get-AzDataMigrationToSqlVM', 'Invoke-AzDataMigrationCutoverToSqlManagedInstance', 'Invoke-AzDataMigrationCutoverToSqlVM', 'New-AzDataMigrationSqlService', 'New-AzDataMigrationSqlServiceAuthKey', 'New-AzDataMigrationToSqlManagedInstance', 'New-AzDataMigrationToSqlVM', 'Register-AzDataMigrationIntegrationRuntime', 'Remove-AzDataMigrationSqlService', 'Remove-AzDataMigrationSqlServiceNode', 'Stop-AzDataMigrationToSqlManagedInstance', 'Stop-AzDataMigrationToSqlVM', 'Update-AzDataMigrationSqlService', '*'
FunctionsToExport = 'Get-AzDataMigrationAssessment', 'Get-AzDataMigrationPerformanceDataCollection', 'Get-AzDataMigrationSkuRecommendation', 'Get-AzDataMigrationSqlService', 'Get-AzDataMigrationSqlServiceAuthKey', 'Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric', 'Get-AzDataMigrationSqlServiceMigration', 'Get-AzDataMigrationToSqlDb', 'Get-AzDataMigrationToSqlManagedInstance', 'Get-AzDataMigrationToSqlVM', 'Invoke-AzDataMigrationCutoverToSqlManagedInstance', 'Invoke-AzDataMigrationCutoverToSqlVM', 'New-AzDataMigrationSqlService', 'New-AzDataMigrationSqlServiceAuthKey', 'New-AzDataMigrationToSqlDb', 'New-AzDataMigrationToSqlManagedInstance', 'New-AzDataMigrationToSqlVM', 'Register-AzDataMigrationIntegrationRuntime', 'Remove-AzDataMigrationSqlService', 'Remove-AzDataMigrationSqlServiceNode', 'Remove-AzDataMigrationToSqlDb', 'Stop-AzDataMigrationToSqlDb', 'Stop-AzDataMigrationToSqlManagedInstance', 'Stop-AzDataMigrationToSqlVM', 'Update-AzDataMigrationSqlService', '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Original file line number Diff line number Diff line change
@@ -146,4 +146,3 @@ function Get-AzDataMigrationPerformanceDataCollection
}
}


6 changes: 3 additions & 3 deletions src/DataMigration/DataMigration.Autorest/custom/readme.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ For `Az.DataMigration` to use custom cmdlets, it does this two different ways. W

For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.DataMigration.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder.

For script cmdlets, these are loaded via the `Az.DataMigration.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundemental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.
For script cmdlets, these are loaded via the `Az.DataMigration.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.

## Purpose
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder.
@@ -32,10 +32,10 @@ These provide functionality to our HTTP pipeline and other useful features. In s
### Attributes
For processing the cmdlets, we've created some additional attributes:
- `Microsoft.Azure.PowerShell.Cmdlets.DataMigration.DescriptionAttribute`
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
- `Microsoft.Azure.PowerShell.Cmdlets.DataMigration.DoNotExportAttribute`
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.DataMigration`.
- `Microsoft.Azure.PowerShell.Cmdlets.DataMigration.InternalExportAttribute`
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.DataMigration`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder.
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.DataMigration`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
- `Microsoft.Azure.PowerShell.Cmdlets.DataMigration.ProfileAttribute`
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
12 changes: 12 additions & 0 deletions src/DataMigration/DataMigration.Autorest/docs/Az.DataMigration.md
Original file line number Diff line number Diff line change
@@ -32,6 +32,9 @@ Retrieve the registered Integration Runtime nodes and their monitoring data for
### [Get-AzDataMigrationSqlServiceMigration](Get-AzDataMigrationSqlServiceMigration.md)
Retrieve the List of database migrations attached to the service.

### [Get-AzDataMigrationToSqlDb](Get-AzDataMigrationToSqlDb.md)
Retrieve the specified database migration for a given SQL Db.

### [Get-AzDataMigrationToSqlManagedInstance](Get-AzDataMigrationToSqlManagedInstance.md)
Retrieve the specified database migration for a given SQL Managed Instance.

@@ -50,6 +53,9 @@ Create or Update Database Migration Service.
### [New-AzDataMigrationSqlServiceAuthKey](New-AzDataMigrationSqlServiceAuthKey.md)
Regenerate a new set of Authentication Keys for Self Hosted Integration Runtime.

### [New-AzDataMigrationToSqlDb](New-AzDataMigrationToSqlDb.md)
Create a new database migration to a given SQL Db.

### [New-AzDataMigrationToSqlManagedInstance](New-AzDataMigrationToSqlManagedInstance.md)
Create a new database migration to a given SQL Managed Instance.

@@ -65,6 +71,12 @@ Delete Database Migration Service.
### [Remove-AzDataMigrationSqlServiceNode](Remove-AzDataMigrationSqlServiceNode.md)
Delete the integration runtime node.

### [Remove-AzDataMigrationToSqlDb](Remove-AzDataMigrationToSqlDb.md)
Remove the specified database migration for a given SQL Db.

### [Stop-AzDataMigrationToSqlDb](Stop-AzDataMigrationToSqlDb.md)
Stop in-progress database migration to SQL Db.

### [Stop-AzDataMigrationToSqlManagedInstance](Stop-AzDataMigrationToSqlManagedInstance.md)
Stop in-progress database migration to SQL Managed Instance.

Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20211030Preview.ISqlMigrationService
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.ISqlMigrationService
## NOTES
@@ -201,6 +201,7 @@ INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
- `[Id <String>]`: Resource identity path
- `[ManagedInstanceName <String>]`:
- `[ResourceGroupName <String>]`: Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
- `[SqlDbInstanceName <String>]`:
- `[SqlMigrationServiceName <String>]`: Name of the SQL Migration Service.
- `[SqlVirtualMachineName <String>]`:
- `[SubscriptionId <String>]`: Subscription ID that identifies an Azure subscription.
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20211030Preview.IAuthenticationKeys
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IAuthenticationKeys
## NOTES
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20211030Preview.IIntegrationRuntimeMonitoringData
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IIntegrationRuntimeMonitoringData
## NOTES
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20211030Preview.IDatabaseMigration
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigration
## NOTES
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
---
external help file:
Module Name: Az.DataMigration
online version: https://docs.microsoft.com/powershell/module/az.datamigration/get-azdatamigrationtosqldb
schema: 2.0.0
---

# Get-AzDataMigrationToSqlDb

## SYNOPSIS
Retrieve the specified database migration for a given SQL Db.

## SYNTAX

### Get (Default)
```
Get-AzDataMigrationToSqlDb -ResourceGroupName <String> -SqlDbInstanceName <String> -TargetDbName <String>
[-SubscriptionId <String[]>] [-Expand <String>] [-MigrationOperationId <String>] [-DefaultProfile <PSObject>]
[-PassThru] [<CommonParameters>]
```

### GetViaIdentity
```
Get-AzDataMigrationToSqlDb -InputObject <IDataMigrationIdentity> [-Expand <String>]
[-MigrationOperationId <String>] [-DefaultProfile <PSObject>] [-PassThru] [<CommonParameters>]
```

## DESCRIPTION
Retrieve the specified database migration for a given SQL Db.

## EXAMPLES

### Example 1: Get the details of a given Database Migration to a SQL DB
```powershell
Get-AzDataMigrationToSqlDb -ResourceGroupName "myRG" -SqlDbInstanceName "mySqlDb" -TargetDbName "mydb1"
```

```output
Name Kind ProvisioningState MigrationStatus
---- ---- ----------------- ---------------
mydb1 SqlDb Succeeded InProgress
```

Get the details of a given Database Migration to a SQL DB

### Example 2: Get the expanded details of a given Database Migration to a SQL DB
```powershell
$dbMigration = Get-AzDataMigrationToSqlDb -ResourceGroupName "myRG" -SqlDbInstanceName "mySqlDb" -TargetDbName "mydb1" -Expand MigrationStatusDetails
$dbMigration.MigrationStatusDetailMigrationState
```

```output
MonitorMigration
```

Get the expanded details of a given Database Migration to a SQL DB

## PARAMETERS

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: System.Management.Automation.PSObject
Parameter Sets: (All)
Aliases: AzureRMContext, AzureCredential

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Expand
Complete migration details be included in the response.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -InputObject
Identity Parameter
To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.IDataMigrationIdentity
Parameter Sets: GetViaIdentity
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -MigrationOperationId
Optional migration operation ID.
If this is provided, then details of migration operation for that ID are retrieved.
If not provided (default), then details related to most recent or current operation are retrieved.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -PassThru
Returns true when the command succeeds
```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
```
### -ResourceGroupName
Name of the resource group that contains the resource.
You can obtain this value from the Azure Resource Manager API or the portal.
```yaml
Type: System.String
Parameter Sets: Get
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SqlDbInstanceName
.
```yaml
Type: System.String
Parameter Sets: Get
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SubscriptionId
Subscription ID that identifies an Azure subscription.
```yaml
Type: System.String[]
Parameter Sets: Get
Aliases:

Required: False
Position: Named
Default value: (Get-AzContext).Subscription.Id
Accept pipeline input: False
Accept wildcard characters: False
```
### -TargetDbName
The name of the target database.
```yaml
Type: System.String
Parameter Sets: Get
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.IDataMigrationIdentity
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlDb
## NOTES
ALIASES
COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
- `[Id <String>]`: Resource identity path
- `[ManagedInstanceName <String>]`:
- `[ResourceGroupName <String>]`: Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
- `[SqlDbInstanceName <String>]`:
- `[SqlMigrationServiceName <String>]`: Name of the SQL Migration Service.
- `[SqlVirtualMachineName <String>]`:
- `[SubscriptionId <String>]`: Subscription ID that identifies an Azure subscription.
- `[TargetDbName <String>]`: The name of the target database.

## RELATED LINKS

Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ Accept wildcard characters: False
```
### -Expand
The child resources to include in the response.
Complete migration details be included in the response.
```yaml
Type: System.String
@@ -207,7 +207,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20211030Preview.IDatabaseMigrationSqlMi
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlMi
## NOTES
@@ -222,6 +222,7 @@ INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
- `[Id <String>]`: Resource identity path
- `[ManagedInstanceName <String>]`:
- `[ResourceGroupName <String>]`: Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
- `[SqlDbInstanceName <String>]`:
- `[SqlMigrationServiceName <String>]`: Name of the SQL Migration Service.
- `[SqlVirtualMachineName <String>]`:
- `[SubscriptionId <String>]`: Subscription ID that identifies an Azure subscription.
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ Accept wildcard characters: False
```
### -Expand
The child resources to include in the response.
Complete migration details be included in the response.
```yaml
Type: System.String
@@ -207,7 +207,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20211030Preview.IDatabaseMigrationSqlVM
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlVM
## NOTES
@@ -222,6 +222,7 @@ INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
- `[Id <String>]`: Resource identity path
- `[ManagedInstanceName <String>]`:
- `[ResourceGroupName <String>]`: Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
- `[SqlDbInstanceName <String>]`:
- `[SqlMigrationServiceName <String>]`: Name of the SQL Migration Service.
- `[SqlVirtualMachineName <String>]`:
- `[SubscriptionId <String>]`: Subscription ID that identifies an Azure subscription.
Loading

0 comments on commit dae72ea

Please sign in to comment.