Skip to content

Commit f543dcf

Browse files
Move DataMigration to main (Azure#18185)
* Move DataMigration to main * Update changelog Co-authored-by: azure-powershell-bot <65331932+azure-powershell-bot@users.noreply.github.com>
1 parent 0981466 commit f543dcf

File tree

202 files changed

+897
-784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+897
-784
lines changed

src/DataMigration/DataMigration.Autorest/check-dependencies.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(-not $Isolated) {
2525
function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) {
2626
if($predicate) {
2727
$module = Get-Module -ListAvailable -Name $moduleName
28-
if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0)) {
28+
if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0) -or ($requiredVersion -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -eq [System.Version]$requiredVersion } | Measure-Object).Count -eq 0)) {
2929
$null = New-Item -ItemType Directory -Force -Path $path
3030
Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..."
3131
if ($requiredVersion) {

src/DataMigration/DataMigration.Autorest/custom/Cmdlets/Get-AzDataMigrationPerformanceDataCollection.ps1

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ function Get-AzDataMigrationPerformanceDataCollection
5050
[System.String]
5151
${ConfigFilePath},
5252

53+
[Parameter(HelpMessage = 'Duration of time in seconds for which you want to collect performance data')]
54+
[System.Int64]
55+
${Time},
56+
5357
[Parameter()]
5458
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Category('Runtime')]
5559
[System.Management.Automation.SwitchParameter]
@@ -122,13 +126,65 @@ function Get-AzDataMigrationPerformanceDataCollection
122126
}
123127

124128
# Running PerfDataCollection
125-
& $ExePath PerfDataCollection @splat
126-
129+
If($PSBoundParameters.ContainsKey("Time"))
130+
{
131+
#this is used to create a json file in case the perf collection is to be time based
132+
$jsonHash = [Ordered]@{
133+
'action' = "PerfDataCollection"
134+
'sqlConnectionStrings'= $SqlConnectionStrings
135+
'outputfolder'= $OutputFolder
136+
'perfQueryIntervalInSec'= $PerfQueryInterval
137+
'staticQueryIntervalInSec'= $StaticQueryInterval
138+
'numberOfIterations'= $NumberOfIterations
139+
}
140+
# removing empty key,vallue pairs from $jsonHash
141+
if($OutputFolder -eq "")
142+
{
143+
$jsonHash.Remove('outputfolder')
144+
}
145+
if($PerfQueryInterval -eq "")
146+
{
147+
$jsonHash.Remove('perfQueryIntervalInSec')
148+
}
149+
if($StaticQueryInterval -eq "")
150+
{
151+
$jsonHash.Remove('staticQueryIntervalInSec')
152+
}
153+
if($NumberOfIterations -eq "")
154+
{
155+
$jsonHash.Remove('numberOfIterations')
156+
}
157+
158+
$saveAt = Join-Path -Path $DefaultOutputFolder -ChildPath Downloads;
159+
$saveas = Join-Path -Path $saveAt -ChildPath "tempConfigFileForPerf.json"
160+
$jsonHash | ConvertTo-Json -depth 100 | Set-Content $saveas
161+
$pro = Start-Process -FilePath $ExePath -ArgumentList "--configFile ""$saveas""" -PassThru -NoNewWindow
162+
Start-Sleep -Seconds $Time
163+
$pro | stop-process
164+
Remove-Item -Path $saveas
165+
}
166+
else
167+
{
168+
& $ExePath PerfDataCollection @splat
169+
}
127170
}
128171
else
129172
{
130-
Test-ConfigFile $PSBoundParameters.ConfigFilePath "PerfDataCollection"
131-
& $ExePath --configFile $PSBoundParameters.ConfigFilePath
173+
if($PSBoundParameters.ContainsKey("Time"))
174+
{
175+
$paramPath = $PSBoundParameters.ConfigFilePath
176+
Test-ConfigFile $PSBoundParameters.ConfigFilePath "PerfDataCollection"
177+
$pro = Start-Process -FilePath $ExePath -ArgumentList "--configFile ""$paramPath""" -PassThru -NoNewWindow
178+
Start-Sleep -Seconds $Time
179+
$pro | stop-process
180+
181+
}
182+
else{
183+
Test-ConfigFile $PSBoundParameters.ConfigFilePath "PerfDataCollection"
184+
& $ExePath --configFile $PSBoundParameters.ConfigFilePath
185+
}
186+
187+
132188
}
133189

134190
$LogFilePath = Join-Path -Path $DefaultOutputFolder -ChildPath Logs;

src/DataMigration/DataMigration.Autorest/custom/Cmdlets/Register-AzDataMigrationIntegrationRuntime.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function Register-AzDataMigrationIntegrationRuntime
5050
# Entry point
5151
$OSPlatform = Get-OSName
5252

53+
# Validate if OS is windows, as currently SHIR is only supported in Windows
5354
if(-not $OSPlatform.Contains("Windows"))
5455
{
5556
throw "This command cannot be run in non-windows environment"
@@ -63,9 +64,10 @@ function Register-AzDataMigrationIntegrationRuntime
6364
throw "Failed: You do not have Administrator rights to run this command!`nPlease re-run this command as an Administrator!"
6465
Break
6566
}
66-
67+
68+
# Validate if given authKey is not empty
6769
$null = Validate-Input $PSBoundParameters.AuthKey
68-
70+
# If SHIR MSI path is provided Perform installation of SHIR
6971
if($PSBoundParameters.ContainsKey("IntegrationRuntimePath"))
7072
{
7173
$path = $PSBoundParameters.IntegrationRuntimePath
@@ -87,15 +89,17 @@ function Register-AzDataMigrationIntegrationRuntime
8789

8890
}
8991

92+
# Check if SHIR is Installed or not
9093
if(-Not (Check-WhetherGatewayInstalled("Microsoft Integration Runtime")))
9194
{
9295
throw "Failed: No installed Integration Runtime found!"
9396
}
9497

9598
if($PSCmdlet.ShouldProcess('Microsoft Integration Runtime','Register AuthKey'))
9699
{
100+
# Register authkeys on SHIR
97101
$result = Register-IR $PSBoundParameters.AuthKey
98-
102+
# Returns True, if command ran successfully and -PassThru parameter is specified
99103
if($PSBoundParameters.ContainsKey("PassThru"))
100104
{
101105
return $result;

src/DataMigration/DataMigration.Autorest/custom/Helpers/IRRegister.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ function Install-Gateway {
2929
)
3030

3131
process {
32-
32+
# Check if SHIR is installed or not. If yes, don't install again
3333
if(Check-WhetherGatewayInstalled("Microsoft Integration Runtime"))
3434
{
3535
Write-Host "Microsoft Integration Runtime is already installed."
3636
return
3737
}
38-
38+
# If not installed start installation
3939
Write-Host "Start Gateway installation"
4040

4141
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$path`" /quiet /passive" -Wait
@@ -55,10 +55,12 @@ function Check-WhetherGatewayInstalled {
5555
)
5656

5757
process{
58-
58+
59+
# Check the uninstall software path in Registry to see if SHIR is installed or not.
5960
$installedSoftwares = Get-ChildItem "hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
6061
foreach ($installedSoftware in $installedSoftwares)
61-
{
62+
{
63+
# DisplayName contains the name of the software
6264
$displayName = $installedSoftware.GetValue("DisplayName")
6365
if($DisplayName -eq "$name Preview" -or $DisplayName -eq "$name")
6466
{
@@ -76,7 +78,7 @@ function Get-CmdFilePath {
7678
param()
7779

7880
process{
79-
81+
# Use Registry to get the installed path of SHIR
8082
$filePath = Get-ItemPropertyValue "hklm:\Software\Microsoft\DataTransfer\DataManagementGateway\ConfigurationManager" "DiacmdPath"
8183
if ([string]::IsNullOrEmpty($filePath))
8284
{
@@ -112,7 +114,7 @@ function Register-IR {
112114
# Open Intranet Port (Necessary for Re-Register. Service has to be running for Re-Register to work.)
113115
Start-Process $dmgCmdPath "-EnableRemoteAccess 8060" -Wait
114116

115-
# Register/ Re-register IR
117+
# Register/ Re-register IR (6>&1 is used to capture the output of script)
116118
$result = & $regIRScriptPath -gatewayKey $key 6>&1
117119
if($result.ToString().Contains("successful"))
118120
{

src/DataMigration/DataMigration.Autorest/docs/Get-AzDataMigrationPerformanceDataCollection.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Collect performance data for given SQL Server instance(s)
1515
### CommandLine (Default)
1616
```
1717
Get-AzDataMigrationPerformanceDataCollection -SqlConnectionStrings <String[]> [-NumberOfIterations <String>]
18-
[-OutputFolder <String>] [-PerfQueryInterval <String>] [-StaticQueryInterval <String>] [-PassThru]
19-
[<CommonParameters>]
18+
[-OutputFolder <String>] [-PerfQueryInterval <String>] [-StaticQueryInterval <String>] [-Time <Int64>]
19+
[-PassThru] [<CommonParameters>]
2020
```
2121

2222
### ConfigFile
2323
```
24-
Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath <String> [-PassThru] [<CommonParameters>]
24+
Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath <String> [-Time <Int64>] [-PassThru]
25+
[<CommonParameters>]
2526
```
2627

2728
## DESCRIPTION
@@ -32,7 +33,9 @@ Collect performance data for given SQL Server instance(s)
3233
### Example 1: Run Performance Data Collection on given SQL Server using connection string
3334
```powershell
3435
PS C:\> Get-AzDataMigrationPerformanceDataCollection -SqlConnectionStrings "Data Source=AALAB03-2K8.REDMOND.CORP.MICROSOFT.COM;Initial Catalog=master;Integrated Security=False;User Id=dummyUserId;Password=dummyPassword" -NumberOfIterations 2
36+
```
3537

38+
```output
3639
Connecting to the SQL server(s)...
3740
Starting data collection...
3841
Press the Enter key to stop the data collection at any time...
@@ -60,7 +63,9 @@ This command runs Performance Data Collection on given SQL Server using the conn
6063
### Example 2: Run Performance Data Collection on given SQL Server using assessment config file
6164
```powershell
6265
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json"
66+
```
6367

68+
```output
6469
Connecting to the SQL server(s)...
6570
Starting data collection...
6671
Press the Enter key to stop the data collection at any time...
@@ -85,6 +90,36 @@ Event and Error Logs Folder Path: C:\Users\vmanhas\AppData\Local\Microsoft\SqlAs
8590

8691
This command runs Performance Data Collection on given SQL Server using the config file.
8792

93+
### Example 3: Run Performance Data Collection on given SQL Server that stops after a specified time
94+
```powershell
95+
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json" -Time 120
96+
```
97+
98+
```output
99+
Connecting to the SQL server(s)...
100+
Starting data collection...
101+
Press the Enter key to stop the data collection at any time...
102+
103+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
104+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
105+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
106+
UTC 2022-02-03 07:04:50, Server AALAB03-2K8:
107+
Performance data query iteration: 1 of 2, collected 349 data points.
108+
UTC 2022-02-03 07:04:52, Server AALAB03-2K8:
109+
Collected static configuration data, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
110+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
111+
UTC 2022-02-03 07:05:44, Server AALAB03-2K8:
112+
Performance data query iteration: 2 of 2, collected 347 data points.
113+
UTC 2022-02-03 07:07:13, Server AALAB03-2K8:
114+
Aggregated 696 raw data points to 263 performance counters, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
115+
UTC 2022-02-03 07:07:16, Server AALAB03-2K8:
116+
Performance data query iteration: 1 of 2, collected 349 data points.
117+
118+
Event and Error Logs Folder Path: C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment\Logs
119+
```
120+
121+
This command runs Performance Data Collection on given SQL Server that stops after a specified time.
122+
88123
## PARAMETERS
89124

90125
### -ConfigFilePath
@@ -196,6 +231,21 @@ Accept pipeline input: False
196231
Accept wildcard characters: False
197232
```
198233
234+
### -Time
235+
Duration of time in seconds for which you want to collect performance data
236+
237+
```yaml
238+
Type: System.Int64
239+
Parameter Sets: (All)
240+
Aliases:
241+
242+
Required: False
243+
Position: Named
244+
Default value: None
245+
Accept pipeline input: False
246+
Accept wildcard characters: False
247+
```
248+
199249
### CommonParameters
200250
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).
201251

src/DataMigration/DataMigration.Autorest/docs/Get-AzDataMigrationSkuRecommendation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ Gives SKU recommendations for Azure SQL offerings
3333
### Example 1: Run SKU Recommendation on given SQL Server using connection string
3434
```powershell
3535
PS C:\> Get-AzDataMigrationSkuRecommendation -DisplayResult
36+
```
3637

38+
```output
3739
Starting SKU recommendation...
3840
3941
Performing aggregation for instance AALAB03-2K8...
@@ -60,7 +62,9 @@ This command runs Run SKU Recommendation on given SQL Server using the connectio
6062
### Example 2: Run Run SKU Recommendation on given SQL Server using assessment config file
6163
```powershell
6264
PS C:\> Get-AzDataMigrationSkuRecommendation -ConfigFilePath "C:\Users\user\document\config.json"
65+
```
6366

67+
```output
6468
Starting SKU recommendation...
6569
6670
Performing aggregation for instance AALAB03-2K8...

src/DataMigration/DataMigration.Autorest/docs/New-AzDataMigrationToSqlDb.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ Create a new database migration to a given SQL Db.
3232

3333
### Example 1: Start a Database Migration from the on-premise Source Sql Server to target Sql Db
3434
```powershell
35-
New-AzDataMigrationToSqlDb -ResourceGroupName myRG -SqlDbInstanceName "mysqldb" -MigrationService "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.DataMigration/SqlMigrationServices/myDMS" -TargetSqlConnectionAuthentication "SqlAuthentication" -TargetSqlConnectionDataSource "mydb.windows.net" -TargetSqlConnectionPassword "pass" -TargetSqlConnectionUserName "user" -SourceSqlConnectionAuthentication "SqlAuthentication" -SourceSqlConnectionDataSource "xyz.MICROSOFT.COM" -SourceSqlConnectionUserName "user1" -SourceSqlConnectionPassword "password" -SourceDatabaseName "sourcedb" -TargetDbName "mydb1" -Scope "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.Sql/servers/mysqldb"
35+
$sourcePassword = ConvertTo-SecureString "pass123" -AsPlainText -Force
36+
$targetPassword = ConvertTo-SecureString "pass123" -AsPlainText -Force
37+
New-AzDataMigrationToSqlDb -ResourceGroupName myRG -SqlDbInstanceName "mysqldb" -MigrationService "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.DataMigration/SqlMigrationServices/myDMS" -TargetSqlConnectionAuthentication "SqlAuthentication" -TargetSqlConnectionDataSource "mydb.windows.net" -TargetSqlConnectionPassword $targetPassword -TargetSqlConnectionUserName "user" -SourceSqlConnectionAuthentication "SqlAuthentication" -SourceSqlConnectionDataSource "xyz.MICROSOFT.COM" -SourceSqlConnectionUserName "user1" -SourceSqlConnectionPassword $sourcePassword -SourceDatabaseName "sourcedb" -TargetDbName "mydb1" -Scope "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.Sql/servers/mysqldb"
38+
3639
```
3740

3841
```output

src/DataMigration/DataMigration.Autorest/docs/Remove-AzDataMigrationToSqlDb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ Remove the specified database migration for a given SQL Db.
3232

3333
### Example 1: Delete the SQL DB Database Migration resource.
3434
```powershell
35-
Remove-AzDataMigrationToSqlDb -ResourceGroupName tsum38RG -SqlDbInstanceName dmstestsqldb -TargetDbName at_sqldbtrgtps1
35+
Remove-AzDataMigrationToSqlDb -ResourceGroupName myRG -SqlDbInstanceName sqldb -TargetDbName myDB
3636
```
3737

3838
Delete the SQL DB Database Migration resource.
3939

4040
### Example 2: Delete the SQL DB Database Migration resource even if it is in progress
4141
```powershell
42-
Remove-AzDataMigrationToSqlDb -ResourceGroupName tsum38RG -SqlDbInstanceName dmstestsqldb -TargetDbName at_sqldbtrgtps1 -Force
42+
Remove-AzDataMigrationToSqlDb -ResourceGroupName myRG -SqlDbInstanceName sqldb -TargetDbName myDB -Force
4343
```
4444

4545
Forcibly deletes an ongoing Migration to SQL DB by adding the optional "Force" parameter

src/DataMigration/DataMigration.Autorest/examples/Get-AzDataMigrationPerformanceDataCollection.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
### Example 1: Run Performance Data Collection on given SQL Server using connection string
22
```powershell
33
PS C:\> Get-AzDataMigrationPerformanceDataCollection -SqlConnectionStrings "Data Source=AALAB03-2K8.REDMOND.CORP.MICROSOFT.COM;Initial Catalog=master;Integrated Security=False;User Id=dummyUserId;Password=dummyPassword" -NumberOfIterations 2
4+
```
45

6+
```output
57
Connecting to the SQL server(s)...
68
Starting data collection...
79
Press the Enter key to stop the data collection at any time...
@@ -30,7 +32,9 @@ This command runs Performance Data Collection on given SQL Server using the conn
3032
### Example 2: Run Performance Data Collection on given SQL Server using assessment config file
3133
```powershell
3234
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json"
35+
```
3336

37+
```output
3438
Connecting to the SQL server(s)...
3539
Starting data collection...
3640
Press the Enter key to stop the data collection at any time...
@@ -56,4 +60,35 @@ Event and Error Logs Folder Path: C:\Users\vmanhas\AppData\Local\Microsoft\SqlAs
5660
This command runs Performance Data Collection on given SQL Server using the config file.
5761

5862

63+
### Example 3: Run Performance Data Collection on given SQL Server that stops after a specified time
64+
```powershell
65+
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json" -Time 120
66+
```
67+
68+
```output
69+
Connecting to the SQL server(s)...
70+
Starting data collection...
71+
Press the Enter key to stop the data collection at any time...
72+
73+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
74+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
75+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
76+
UTC 2022-02-03 07:04:50, Server AALAB03-2K8:
77+
Performance data query iteration: 1 of 2, collected 349 data points.
78+
UTC 2022-02-03 07:04:52, Server AALAB03-2K8:
79+
Collected static configuration data, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
80+
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
81+
UTC 2022-02-03 07:05:44, Server AALAB03-2K8:
82+
Performance data query iteration: 2 of 2, collected 347 data points.
83+
UTC 2022-02-03 07:07:13, Server AALAB03-2K8:
84+
Aggregated 696 raw data points to 263 performance counters, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
85+
UTC 2022-02-03 07:07:16, Server AALAB03-2K8:
86+
Performance data query iteration: 1 of 2, collected 349 data points.
87+
88+
Event and Error Logs Folder Path: C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment\Logs
89+
```
90+
91+
This command runs Performance Data Collection on given SQL Server that stops after a specified time.
92+
93+
5994

0 commit comments

Comments
 (0)