Skip to content

Commit a57f1a8

Browse files
Migrate DataMigration from generation to main (#23991)
* Move DataMigration to main * Updating changelog.md --------- Co-authored-by: Yunchi Wang <[email protected]>
1 parent 755712c commit a57f1a8

File tree

5 files changed

+61
-12
lines changed

5 files changed

+61
-12
lines changed

src/DataMigration/DataMigration.Autorest/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For information on how to develop for `Az.DataMigration`, see [how-to.md](how-to
3030
> see https://aka.ms/autorest
3131
3232
``` yaml
33-
branch: e8c359d8821038f133695c9b1f4cf40d330cbc80
33+
commit: e8c359d8821038f133695c9b1f4cf40d330cbc80
3434
require:
3535
- $(this-folder)/../../readme.azure.noprofile.md
3636
input-file:
@@ -39,6 +39,10 @@ input-file:
3939
title: DataMigration
4040
module-version: 0.1.0
4141

42+
# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
43+
use-extension:
44+
"@autorest/powershell": "3.x"
45+
4246
directive:
4347

4448
#Swagger description changes

src/DataMigration/DataMigration.Autorest/custom/Cmdlets/New-AzDataMigrationLoginsMigration.ps1

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,59 @@ function New-AzDataMigrationLoginsMigration
9191
#Testing Whether Console App is downloaded or not
9292
$TestExePath = Test-Path -Path $ExePath;
9393

94+
#Console app download address
95+
$ZipSource = "https://sqlassess.blob.core.windows.net/app/LoginsMigration.zip";
96+
$ZipDestination = Join-Path -Path $BaseFolder -ChildPath "LoginsMigration.zip";
97+
9498
#Downloading and extracting LoginsMigration Zip file
9599
if(-Not $TestExePath)
96100
{
97-
$ZipSource = "https://sqlassess.blob.core.windows.net/app/LoginsMigration.zip";
98-
$ZipDestination = Join-Path -Path $BaseFolder -ChildPath "LoginsMigration.zip";
101+
#Downloading and extracting LoginMigration Zip file
102+
Write-Host "Downloading and extracting latest LoginMigration Zip file..."
99103
Invoke-RestMethod -Uri $ZipSource -OutFile $ZipDestination;
100-
101104
Expand-Archive -Path $ZipDestination -DestinationPath $BaseFolder -Force;
102105
}
106+
else
107+
{
108+
# Get local exe version
109+
Write-Host "Checking installed Login.Console.exe version...";
110+
$installedVersion = (Get-Item $ExePath).VersionInfo.FileVersion;
111+
Write-Host "Installed version: $installedVersion";
112+
113+
# Get latest console app version
114+
Write-Host "Checking whether there is newer version...";
115+
$VersionFileSource = "https://sqlassess.blob.core.windows.net/app/loginconsoleappversion.json";
116+
$VersionFileDestination = Join-Path -Path $BaseFolder -ChildPath "loginconsoleappversion.json";
117+
Invoke-RestMethod -Uri $VersionFileSource -OutFile $VersionFileDestination;
118+
$jsonObj = Get-Content $VersionFileDestination | Out-String | ConvertFrom-Json;
119+
$latestVersion = $jsonObj.version;
120+
121+
# Compare the latest exe version with the local exe version
122+
if([System.Version]$installedVersion -lt [System.Version]$latestVersion)
123+
{
124+
Write-Host "Found newer version of Logins.Console.exe '$latestVersion'";
125+
126+
Write-Host "Removing old Logins.Console.exe..."
127+
# Remove old zip file
128+
Remove-Item -Path $ZipDestination;
129+
130+
# Remove existing folder and contents
131+
$ConsoleAppDestination = Join-Path -Path $BaseFolder -ChildPath "Logins.Console.csproj";
132+
Remove-Item -Path $ConsoleAppDestination -Recurse;
133+
134+
# Remove version file
135+
Remove-Item -Path $VersionFileDestination;
136+
137+
#Downloading and extracting LoginMigration Zip file
138+
Write-Host "Downloading and extracting latest LoginMigration Zip file..."
139+
Invoke-RestMethod -Uri $ZipSource -OutFile $ZipDestination;
140+
Expand-Archive -Path $ZipDestination -DestinationPath $BaseFolder -Force;
141+
}
142+
else
143+
{
144+
Write-Host "Installed Logins.Console.exe is the latest one...";
145+
}
146+
}
103147

104148
#Collecting data
105149
if(('CommandLine') -contains $PSCmdlet.ParameterSetName)

src/DataMigration/DataMigration.Autorest/test/Remove-AzDataMigrationToSqlDb.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ Describe 'Remove-AzDataMigrationToSqlDb' {
2020
$sourcePassword = ConvertTo-SecureString $env.TestDeleteDatabaseMigrationDb.SourceSqlConnectionPassword -AsPlainText -Force
2121

2222
$instance = New-AzDataMigrationToSqlDb -ResourceGroupName $env.TestDeleteDatabaseMigrationDb.ResourceGroupName -SqlDbInstanceName $env.TestDeleteDatabaseMigrationDb.SqlDbInstanceName -MigrationService $env.TestDeleteDatabaseMigrationDb.MigrationService -TargetSqlConnectionAuthentication $env.TestDeleteDatabaseMigrationDb.TargetSqlConnectionAuthentication -TargetSqlConnectionDataSource $env.TestDeleteDatabaseMigrationDb.TargetSqlConnectionDataSource -TargetSqlConnectionPassword $targetPassword -TargetSqlConnectionUserName $env.TestDeleteDatabaseMigrationDb.TargetSqlConnectionUserName -SourceSqlConnectionAuthentication $env.TestDeleteDatabaseMigrationDb.SourceSqlConnectionAuthentication -SourceSqlConnectionDataSource $env.TestDeleteDatabaseMigrationDb.SourceSqlConnectionDataSource -SourceSqlConnectionUserName $env.TestDeleteDatabaseMigrationDb.SourceSqlConnectionUserName -SourceSqlConnectionPassword $sourcePassword -SourceDatabaseName $env.TestDeleteDatabaseMigrationDb.SourceDatabaseName -TargetDbName $env.TestDeleteDatabaseMigrationDb.TargetDbName -Scope $env.TestDeleteDatabaseMigrationDb.Scope
23-
24-
Start-TestSleep -Seconds 5
23+
24+
Start-Sleep -Seconds 5
2525

2626
Remove-AzDataMigrationToSqlDb -ResourceGroupName $env.TestDeleteDatabaseMigrationDb.ResourceGroupName -SqlDbInstanceName $env.TestDeleteDatabaseMigrationDb.SqlDbInstanceName -TargetDbName $env.TestDeleteDatabaseMigrationDb.TargetDbName -Force
2727

28-
Start-TestSleep -Seconds 5
29-
30-
28+
Start-Sleep -Seconds 5
29+
30+
3131
$dbMig = Get-AzDataMigrationToSqlDb -ResourceGroupName $env.TestDeleteDatabaseMigrationDb.ResourceGroupName -SqlDbInstanceName $env.TestDeleteDatabaseMigrationDb.SqlDbInstanceName -TargetDbName $env.TestDeleteDatabaseMigrationDb.TargetDbName -ErrorAction SilentlyContinue
32-
32+
3333

3434
$assert = ($dbMig -eq $null)
3535
$assert | Should be $true

src/DataMigration/DataMigration/Az.DataMigration.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 12/5/2023
6+
# Generated on: 1/18/2024
77
#
88

99
@{
@@ -53,7 +53,7 @@ DotNetFrameworkVersion = '4.7.2'
5353
# ProcessorArchitecture = ''
5454

5555
# Modules that must be imported into the global environment prior to importing this module
56-
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.13.2'; })
56+
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.15.0'; })
5757

5858
# Assemblies that must be loaded prior to importing this module
5959
RequiredAssemblies = 'DataMigration.Autorest/bin/Az.DataMigration.private.dll',

src/DataMigration/DataMigration/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added versioning to login migration console app.
2122

2223
## Version 0.14.3
2324
* Supported console app automatically upgrade.

0 commit comments

Comments
 (0)