Skip to content

Commit 662d0ec

Browse files
Migrate DataMigration from generation to main (Azure#19608)
* Move DataMigration to main * update docs Co-authored-by: wyunchi-ms <[email protected]>
1 parent 0619ab7 commit 662d0ec

File tree

195 files changed

+2131
-927
lines changed

Some content is hidden

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

195 files changed

+2131
-927
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
<#
16+
.Synopsis
17+
Migrate logins from the source Sql Servers to the target Azure Sql Servers.
18+
.Description
19+
Migrate logins from the source Sql Servers to the target Azure Sql Servers.
20+
#>
21+
22+
23+
function New-AzDataMigrationLoginsMigration
24+
{
25+
[OutputType([System.Boolean])]
26+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
27+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Description('Migrate logins from the source Sql Servers to the target Azure Sql Servers.')]
28+
29+
param(
30+
[Parameter(ParameterSetName='CommandLine', Mandatory, HelpMessage='Required. Connection string(s) for the source SQL instance(s), using the formal connection string format.')]
31+
[System.String[]]
32+
${SourceSqlConnectionString},
33+
34+
35+
[Parameter(ParameterSetName='CommandLine', Mandatory, HelpMessage='Required. Connection string(s) for the target SQL instance(s), using the formal connection string format.')]
36+
[System.String]
37+
${TargetSqlConnectionString},
38+
39+
[Parameter(ParameterSetName='CommandLine', HelpMessage='Optional. Location of CSV file of logins. Use only one parameter between this and listOfLogin.')]
40+
[System.String]
41+
${CSVFilePath},
42+
43+
[Parameter(ParameterSetName='CommandLine', HelpMessage='Optional. List of logins in string format. If large number of logins need to be migrated, use CSV file option.')]
44+
[System.String[]]
45+
${ListOfLogin},
46+
47+
[Parameter(ParameterSetName='CommandLine', HelpMessage='Optional. Default: %LocalAppData%/Microsoft/SqlLoginMigrations) Folder where logs will be written.')]
48+
[System.String]
49+
${OutputFolder},
50+
51+
[Parameter(ParameterSetName='CommandLine', HelpMessage='Optional. Required if Windows logins are included in the list of logins to be migrated. (Default: empty string).')]
52+
[System.String]
53+
${AADDomainName},
54+
55+
[Parameter(ParameterSetName='ConfigFile', Mandatory, HelpMessage='Path of the ConfigFile')]
56+
[System.String]
57+
${ConfigFilePath},
58+
59+
[Parameter()]
60+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Category('Runtime')]
61+
[System.Management.Automation.SwitchParameter]
62+
# Returns true when the command succeeds
63+
${PassThru}
64+
)
65+
66+
process
67+
{
68+
try
69+
{
70+
$OSPlatform = Get-OSName
71+
72+
if(-Not $OSPlatform.Contains("Windows"))
73+
{
74+
throw "This command cannot be run in non-windows environment"
75+
Break;
76+
}
77+
78+
#Defining Default Output Path
79+
$DefaultOutputFolder = Get-DefaultLoginMigrationsOutputFolder
80+
81+
#Defining Base and Exe paths
82+
$BaseFolder = Join-Path -Path $DefaultOutputFolder -ChildPath Downloads;
83+
$ExePath = Join-Path -Path $BaseFolder -ChildPath Logins.Console.csproj\Logins.Console.exe;
84+
85+
#Checking if BaseFolder Path is valid or not
86+
if(-Not (Test-Path $BaseFolder))
87+
{
88+
$null = New-Item -Path $BaseFolder -ItemType "directory"
89+
}
90+
91+
#Testing Whether Console App is downloaded or not
92+
$TestExePath = Test-Path -Path $ExePath;
93+
94+
#Downloading and extracting LoginsMigration Zip file
95+
if(-Not $TestExePath)
96+
{
97+
$ZipSource = "https://sqlloginmigration.blob.core.windows.net/app/LoginsMigration.zip";
98+
$ZipDestination = Join-Path -Path $BaseFolder -ChildPath "LoginsMigration.zip";
99+
Invoke-RestMethod -Uri $ZipSource -OutFile $ZipDestination;
100+
101+
Expand-Archive -Path $ZipDestination -DestinationPath $BaseFolder -Force;
102+
}
103+
104+
#Collecting data
105+
if(('CommandLine') -contains $PSCmdlet.ParameterSetName)
106+
{
107+
# The array list $splat contains all the parameters that will be passed to '.\Logins.Console.exe LoginsMigration'
108+
109+
$LoginsListArray = $($ListOfLogin -split " ")
110+
[System.Collections.ArrayList] $splat = @(
111+
'--sourceSqlConnectionString', $SourceSqlConnectionString
112+
'--targetSqlConnectionString', $TargetSqlConnectionString
113+
'--csvFilePath', $CSVFilePath
114+
'--listOfLogin', $LoginsListArray
115+
'--outputFolder', $OutputFolder
116+
'--aadDomainName', $AADDomainName
117+
)
118+
# Removing the parameters for which the user did not provide any values
119+
for($i = $splat.Count-1; $i -gt -1; $i = $i-2)
120+
{
121+
$currVal = $splat[$i]
122+
if($currVal -ne "")
123+
{
124+
}
125+
else {
126+
$splat.RemoveAt($i)
127+
$i2 = $i -1
128+
$splat.RemoveAt($i2)
129+
130+
}
131+
}
132+
# Running LoginsMigration
133+
& $ExePath LoginsMigration @splat
134+
}
135+
else
136+
{
137+
Test-LoginMigrationsConfigFile $PSBoundParameters.ConfigFilePath
138+
& $ExePath --configFile $PSBoundParameters.ConfigFilePath
139+
}
140+
141+
$LogFilePath = Join-Path -Path $DefaultOutputFolder -ChildPath Logs;
142+
Write-Host "Event and Error Logs Folder Path: $LogFilePath";
143+
144+
if($PSBoundParameters.ContainsKey("PassThru"))
145+
{
146+
return $true;
147+
}
148+
}
149+
catch
150+
{
151+
throw $_
152+
}
153+
}
154+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
16+
# Function Definitions
17+
18+
function Test-LoginMigrationsConfigFile{
19+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.DoNotExportAttribute()]
20+
param(
21+
[Parameter(Mandatory=$true)]
22+
[System.String]
23+
$path
24+
)
25+
26+
process {
27+
if (!(Test-Path -Path $path))
28+
{
29+
throw "Invalid Config File path: $path"
30+
}
31+
}
32+
}
33+
34+
function Get-DefaultLoginMigrationsOutputFolder {
35+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.DoNotExportAttribute()]
36+
param(
37+
)
38+
39+
process {
40+
$OSPlatform = Get-OSName
41+
42+
if($OSPlatform.Contains("Linux"))
43+
{
44+
$DefualtPath = Join-Path -Path $env:USERPROFILE -ChildPath ".config\Microsoft\SqlLoginMigrations";
45+
46+
}
47+
elseif ($OSPlatform.Contains("Darwin"))
48+
{
49+
$DefualtPath = Join-Path -Path $env:USERPROFILE -ChildPath "Library\Application Support\Microsoft\SqlLoginMigrations";
50+
}
51+
else
52+
{
53+
$DefualtPath = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Microsoft\SqlLoginMigrations";
54+
}
55+
56+
return $DefualtPath
57+
58+
}
59+
60+
}

src/DataMigration/DataMigration.Autorest/docs/Az.DataMigration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Initiate cutover for in-progress online database migration to SQL Managed Instan
4747
### [Invoke-AzDataMigrationCutoverToSqlVM](Invoke-AzDataMigrationCutoverToSqlVM.md)
4848
Initiate cutover for in-progress online database migration to SQL VM.
4949

50+
### [New-AzDataMigrationLoginsMigration](New-AzDataMigrationLoginsMigration.md)
51+
Migrate logins from the source Sql Servers to the target Azure Sql Servers.
52+
5053
### [New-AzDataMigrationSqlService](New-AzDataMigrationSqlService.md)
5154
Create or Update Database Migration Service.
5255

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Collect performance data for given SQL Server instance(s)
3232

3333
### Example 1: Run Performance Data Collection on given SQL Server using connection string
3434
```powershell
35-
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
35+
Get-AzDataMigrationPerformanceDataCollection -SqlConnectionStrings "Data Source=AALAB03-2K8.REDMOND.CORP.MICROSOFT.COM;Initial Catalog=master;Integrated Security=False;User Id=dummyUserId;Password=dummyPassword" -NumberOfIterations 2
3636
```
3737

3838
```output
@@ -62,7 +62,7 @@ This command runs Performance Data Collection on given SQL Server using the conn
6262

6363
### Example 2: Run Performance Data Collection on given SQL Server using assessment config file
6464
```powershell
65-
PS C:\> Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json"
65+
Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath "C:\Users\user\document\config.json"
6666
```
6767

6868
```output
@@ -92,7 +92,7 @@ This command runs Performance Data Collection on given SQL Server using the conf
9292

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

9898
```output

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Gives SKU recommendations for Azure SQL offerings
3232

3333
### Example 1: Run SKU Recommendation on given SQL Server using connection string
3434
```powershell
35-
PS C:\> Get-AzDataMigrationSkuRecommendation -DisplayResult
35+
Get-AzDataMigrationSkuRecommendation -DisplayResult
3636
```
3737

3838
```output
@@ -61,7 +61,7 @@ This command runs Run SKU Recommendation on given SQL Server using the connectio
6161

6262
### Example 2: Run Run SKU Recommendation on given SQL Server using assessment config file
6363
```powershell
64-
PS C:\> Get-AzDataMigrationSkuRecommendation -ConfigFilePath "C:\Users\user\document\config.json"
64+
Get-AzDataMigrationSkuRecommendation -ConfigFilePath "C:\Users\user\document\config.json"
6565
```
6666

6767
```output

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Get-AzDataMigrationSqlService -ResourceGroupName "MyResourceGroup"
6363
Location Name Type ProvisioningState IntegrationRuntimeState
6464
-------- ---- ---- ----------------- -----------------------
6565
eastus MySqlMigrationService1 Microsoft.DataMigration/sqlMigrationServices Succeeded
66-
eastus2 MySqlMigrationService Microsoft.DataMigration/sqlMigrationServices Succeeded
66+
eastus2 MySqlMigrationService Microsoft.DataMigration/sqlMigrationServices Succeeded
6767
```
6868

6969
This command gets all Sql Migration Services in a given Resource Group.
@@ -78,7 +78,7 @@ Location Name Type
7878
-------- ---- ---- ----------------- -----------------------
7979
eastus MySqlMigrationService1 Microsoft.DataMigration/sqlMigrationServices Succeeded
8080
eastus2 MySqlMigrationService Microsoft.DataMigration/sqlMigrationServices Succeeded
81-
uksouth MySqlMigrationService-UK Microsoft.DataMigration/sqlMigrationServices Succeeded
81+
uksouth MySqlMigrationService-UK Microsoft.DataMigration/sqlMigrationServices Succeeded
8282
```
8383

8484
This command gets all Sql Migration Services in a given Subscription.
@@ -197,7 +197,7 @@ COMPLEX PARAMETER PROPERTIES
197197
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.
198198
199199
200-
INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
200+
`INPUTOBJECT <IDataMigrationIdentity>`: Identity Parameter
201201
- `[Id <String>]`: Resource identity path
202202
- `[ManagedInstanceName <String>]`:
203203
- `[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.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Retrieve the registered Integration Runtime nodes and their monitoring data for
2525

2626
### Example 1: Get the registered Integration Runtime nodes and their monitoring data for a given Sql Migration Service
2727
```powershell
28-
Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric -ResourceGroupName "MyResourceGroup" -SqlMigrationServiceName "MySqlMigrationService" | Select *
28+
Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric -ResourceGroupName "MyResourceGroup" -SqlMigrationServiceName "MySqlMigrationService" | Select-Object *
2929
```
3030

3131
```output
@@ -38,7 +38,7 @@ This command gets the registered Integration Runtime nodes and their monitoring
3838

3939
### Example 2: Print the monitoring data for each Integration Runtime node
4040
```powershell
41-
$item = Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric -ResourceGroupName "MyResourceGroup" -SqlMigrationService "MySqlMigrationService"
41+
$item = Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric -ResourceGroupName "MyResourceGroup" -SqlMigrationServiceName "MySqlMigrationService"
4242
$item.Node[0]
4343
```
4444

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ COMPLEX PARAMETER PROPERTIES
216216
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.
217217
218218
219-
INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
219+
`INPUTOBJECT <IDataMigrationIdentity>`: Identity Parameter
220220
- `[Id <String>]`: Resource identity path
221221
- `[ManagedInstanceName <String>]`:
222222
- `[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.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ COMPLEX PARAMETER PROPERTIES
218218
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.
219219
220220
221-
INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
221+
`INPUTOBJECT <IDataMigrationIdentity>`: Identity Parameter
222222
- `[Id <String>]`: Resource identity path
223223
- `[ManagedInstanceName <String>]`:
224224
- `[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.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ COMPLEX PARAMETER PROPERTIES
218218
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.
219219
220220
221-
INPUTOBJECT <IDataMigrationIdentity>: Identity Parameter
221+
`INPUTOBJECT <IDataMigrationIdentity>`: Identity Parameter
222222
- `[Id <String>]`: Resource identity path
223223
- `[ManagedInstanceName <String>]`:
224224
- `[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.

0 commit comments

Comments
 (0)