Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if(-not $Isolated) {
function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) {
if($predicate) {
$module = Get-Module -ListAvailable -Name $moduleName
if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0)) {
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)) {
$null = New-Item -ItemType Directory -Force -Path $path
Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..."
if ($requiredVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function Get-AzDataMigrationPerformanceDataCollection
[System.String]
${ConfigFilePath},

[Parameter(HelpMessage = 'Duration of time in seconds for which you want to collect performance data')]
[System.Int64]
${Time},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
Expand Down Expand Up @@ -122,13 +126,65 @@ function Get-AzDataMigrationPerformanceDataCollection
}

# Running PerfDataCollection
& $ExePath PerfDataCollection @splat

If($PSBoundParameters.ContainsKey("Time"))
{
#this is used to create a json file in case the perf collection is to be time based
$jsonHash = [Ordered]@{
'action' = "PerfDataCollection"
'sqlConnectionStrings'= $SqlConnectionStrings
'outputfolder'= $OutputFolder
'perfQueryIntervalInSec'= $PerfQueryInterval
'staticQueryIntervalInSec'= $StaticQueryInterval
'numberOfIterations'= $NumberOfIterations
}
# removing empty key,vallue pairs from $jsonHash
if($OutputFolder -eq "")
{
$jsonHash.Remove('outputfolder')
}
if($PerfQueryInterval -eq "")
{
$jsonHash.Remove('perfQueryIntervalInSec')
}
if($StaticQueryInterval -eq "")
{
$jsonHash.Remove('staticQueryIntervalInSec')
}
if($NumberOfIterations -eq "")
{
$jsonHash.Remove('numberOfIterations')
}

$saveAt = Join-Path -Path $DefaultOutputFolder -ChildPath Downloads;
$saveas = Join-Path -Path $saveAt -ChildPath "tempConfigFileForPerf.json"
$jsonHash | ConvertTo-Json -depth 100 | Set-Content $saveas
$pro = Start-Process -FilePath $ExePath -ArgumentList "--configFile ""$saveas""" -PassThru -NoNewWindow
Start-Sleep -Seconds $Time
$pro | stop-process
Remove-Item -Path $saveas
}
else
{
& $ExePath PerfDataCollection @splat
}
}
else
{
Test-ConfigFile $PSBoundParameters.ConfigFilePath "PerfDataCollection"
& $ExePath --configFile $PSBoundParameters.ConfigFilePath
if($PSBoundParameters.ContainsKey("Time"))
{
$paramPath = $PSBoundParameters.ConfigFilePath
Test-ConfigFile $PSBoundParameters.ConfigFilePath "PerfDataCollection"
$pro = Start-Process -FilePath $ExePath -ArgumentList "--configFile ""$paramPath""" -PassThru -NoNewWindow
Start-Sleep -Seconds $Time
$pro | stop-process

}
else{
Test-ConfigFile $PSBoundParameters.ConfigFilePath "PerfDataCollection"
& $ExePath --configFile $PSBoundParameters.ConfigFilePath
}


}

$LogFilePath = Join-Path -Path $DefaultOutputFolder -ChildPath Logs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function Register-AzDataMigrationIntegrationRuntime
# Entry point
$OSPlatform = Get-OSName

# Validate if OS is windows, as currently SHIR is only supported in Windows
if(-not $OSPlatform.Contains("Windows"))
{
throw "This command cannot be run in non-windows environment"
Expand All @@ -63,9 +64,10 @@ function Register-AzDataMigrationIntegrationRuntime
throw "Failed: You do not have Administrator rights to run this command!`nPlease re-run this command as an Administrator!"
Break
}


# Validate if given authKey is not empty
$null = Validate-Input $PSBoundParameters.AuthKey

# If SHIR MSI path is provided Perform installation of SHIR
if($PSBoundParameters.ContainsKey("IntegrationRuntimePath"))
{
$path = $PSBoundParameters.IntegrationRuntimePath
Expand All @@ -87,15 +89,17 @@ function Register-AzDataMigrationIntegrationRuntime

}

# Check if SHIR is Installed or not
if(-Not (Check-WhetherGatewayInstalled("Microsoft Integration Runtime")))
{
throw "Failed: No installed Integration Runtime found!"
}

if($PSCmdlet.ShouldProcess('Microsoft Integration Runtime','Register AuthKey'))
{
# Register authkeys on SHIR
$result = Register-IR $PSBoundParameters.AuthKey

# Returns True, if command ran successfully and -PassThru parameter is specified
if($PSBoundParameters.ContainsKey("PassThru"))
{
return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ function Install-Gateway {
)

process {

# Check if SHIR is installed or not. If yes, don't install again
if(Check-WhetherGatewayInstalled("Microsoft Integration Runtime"))
{
Write-Host "Microsoft Integration Runtime is already installed."
return
}

# If not installed start installation
Write-Host "Start Gateway installation"

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

process{


# Check the uninstall software path in Registry to see if SHIR is installed or not.
$installedSoftwares = Get-ChildItem "hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
foreach ($installedSoftware in $installedSoftwares)
{
{
# DisplayName contains the name of the software
$displayName = $installedSoftware.GetValue("DisplayName")
if($DisplayName -eq "$name Preview" -or $DisplayName -eq "$name")
{
Expand All @@ -76,7 +78,7 @@ function Get-CmdFilePath {
param()

process{

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

# Register/ Re-register IR
# Register/ Re-register IR (6>&1 is used to capture the output of script)
$result = & $regIRScriptPath -gatewayKey $key 6>&1
if($result.ToString().Contains("successful"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ Collect performance data for given SQL Server instance(s)
### CommandLine (Default)
```
Get-AzDataMigrationPerformanceDataCollection -SqlConnectionStrings <String[]> [-NumberOfIterations <String>]
[-OutputFolder <String>] [-PerfQueryInterval <String>] [-StaticQueryInterval <String>] [-PassThru]
[<CommonParameters>]
[-OutputFolder <String>] [-PerfQueryInterval <String>] [-StaticQueryInterval <String>] [-Time <Int64>]
[-PassThru] [<CommonParameters>]
```

### ConfigFile
```
Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath <String> [-PassThru] [<CommonParameters>]
Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath <String> [-Time <Int64>] [-PassThru]
[<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -32,7 +33,9 @@ Collect performance data for given SQL Server instance(s)
### Example 1: Run Performance Data Collection on given SQL Server using connection string
```powershell
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
```

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

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

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

### Example 3: Run Performance Data Collection on given SQL Server that stops after a specified time
```powershell
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json" -Time 120
```

```output
Connecting to the SQL server(s)...
Starting data collection...
Press the Enter key to stop the data collection at any time...

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.
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.
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.
UTC 2022-02-03 07:04:50, Server AALAB03-2K8:
Performance data query iteration: 1 of 2, collected 349 data points.
UTC 2022-02-03 07:04:52, Server AALAB03-2K8:
Collected static configuration data, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
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.
UTC 2022-02-03 07:05:44, Server AALAB03-2K8:
Performance data query iteration: 2 of 2, collected 347 data points.
UTC 2022-02-03 07:07:13, Server AALAB03-2K8:
Aggregated 696 raw data points to 263 performance counters, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
UTC 2022-02-03 07:07:16, Server AALAB03-2K8:
Performance data query iteration: 1 of 2, collected 349 data points.

Event and Error Logs Folder Path: C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment\Logs
```

This command runs Performance Data Collection on given SQL Server that stops after a specified time.

## PARAMETERS

### -ConfigFilePath
Expand Down Expand Up @@ -196,6 +231,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Time
Duration of time in seconds for which you want to collect performance data

```yaml
Type: System.Int64
Parameter Sets: (All)
Aliases:

Required: False
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).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Gives SKU recommendations for Azure SQL offerings
### Example 1: Run SKU Recommendation on given SQL Server using connection string
```powershell
PS C:\> Get-AzDataMigrationSkuRecommendation -DisplayResult
```

```output
Starting SKU recommendation...

Performing aggregation for instance AALAB03-2K8...
Expand All @@ -60,7 +62,9 @@ This command runs Run SKU Recommendation on given SQL Server using the connectio
### Example 2: Run Run SKU Recommendation on given SQL Server using assessment config file
```powershell
PS C:\> Get-AzDataMigrationSkuRecommendation -ConfigFilePath "C:\Users\user\document\config.json"
```

```output
Starting SKU recommendation...

Performing aggregation for instance AALAB03-2K8...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ Create a new database migration to a given SQL Db.

### Example 1: Start a Database Migration from the on-premise Source Sql Server to target Sql Db
```powershell
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"
$sourcePassword = ConvertTo-SecureString "pass123" -AsPlainText -Force
$targetPassword = ConvertTo-SecureString "pass123" -AsPlainText -Force
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"

```

```output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Remove the specified database migration for a given SQL Db.

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

Delete the SQL DB Database Migration resource.

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

Forcibly deletes an ongoing Migration to SQL DB by adding the optional "Force" parameter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
### Example 1: Run Performance Data Collection on given SQL Server using connection string
```powershell
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
```

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

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


### Example 3: Run Performance Data Collection on given SQL Server that stops after a specified time
```powershell
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json" -Time 120
```

```output
Connecting to the SQL server(s)...
Starting data collection...
Press the Enter key to stop the data collection at any time...

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.
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.
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.
UTC 2022-02-03 07:04:50, Server AALAB03-2K8:
Performance data query iteration: 1 of 2, collected 349 data points.
UTC 2022-02-03 07:04:52, Server AALAB03-2K8:
Collected static configuration data, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
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.
UTC 2022-02-03 07:05:44, Server AALAB03-2K8:
Performance data query iteration: 2 of 2, collected 347 data points.
UTC 2022-02-03 07:07:13, Server AALAB03-2K8:
Aggregated 696 raw data points to 263 performance counters, and saved to C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment.
UTC 2022-02-03 07:07:16, Server AALAB03-2K8:
Performance data query iteration: 1 of 2, collected 349 data points.

Event and Error Logs Folder Path: C:\Users\vmanhas\AppData\Local\Microsoft\SqlAssessment\Logs
```

This command runs Performance Data Collection on given SQL Server that stops after a specified time.



Loading