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
6 changes: 5 additions & 1 deletion src/DataMigration/DataMigration.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For information on how to develop for `Az.DataMigration`, see [how-to.md](how-to
> see https://aka.ms/autorest

``` yaml
branch: e8c359d8821038f133695c9b1f4cf40d330cbc80
commit: e8c359d8821038f133695c9b1f4cf40d330cbc80
require:
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
Expand All @@ -39,6 +39,10 @@ input-file:
title: DataMigration
module-version: 0.1.0

# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
use-extension:
"@autorest/powershell": "3.x"

directive:

#Swagger description changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,59 @@ function New-AzDataMigrationLoginsMigration
#Testing Whether Console App is downloaded or not
$TestExePath = Test-Path -Path $ExePath;

#Console app download address
$ZipSource = "https://sqlassess.blob.core.windows.net/app/LoginsMigration.zip";
$ZipDestination = Join-Path -Path $BaseFolder -ChildPath "LoginsMigration.zip";

#Downloading and extracting LoginsMigration Zip file
if(-Not $TestExePath)
{
$ZipSource = "https://sqlassess.blob.core.windows.net/app/LoginsMigration.zip";
$ZipDestination = Join-Path -Path $BaseFolder -ChildPath "LoginsMigration.zip";
#Downloading and extracting LoginMigration Zip file
Write-Host "Downloading and extracting latest LoginMigration Zip file..."
Invoke-RestMethod -Uri $ZipSource -OutFile $ZipDestination;

Expand-Archive -Path $ZipDestination -DestinationPath $BaseFolder -Force;
}
else
{
# Get local exe version
Write-Host "Checking installed Login.Console.exe version...";
$installedVersion = (Get-Item $ExePath).VersionInfo.FileVersion;
Write-Host "Installed version: $installedVersion";

# Get latest console app version
Write-Host "Checking whether there is newer version...";
$VersionFileSource = "https://sqlassess.blob.core.windows.net/app/loginconsoleappversion.json";
$VersionFileDestination = Join-Path -Path $BaseFolder -ChildPath "loginconsoleappversion.json";
Invoke-RestMethod -Uri $VersionFileSource -OutFile $VersionFileDestination;
$jsonObj = Get-Content $VersionFileDestination | Out-String | ConvertFrom-Json;
$latestVersion = $jsonObj.version;

# Compare the latest exe version with the local exe version
if([System.Version]$installedVersion -lt [System.Version]$latestVersion)
{
Write-Host "Found newer version of Logins.Console.exe '$latestVersion'";

Write-Host "Removing old Logins.Console.exe..."
# Remove old zip file
Remove-Item -Path $ZipDestination;

# Remove existing folder and contents
$ConsoleAppDestination = Join-Path -Path $BaseFolder -ChildPath "Logins.Console.csproj";
Remove-Item -Path $ConsoleAppDestination -Recurse;

# Remove version file
Remove-Item -Path $VersionFileDestination;

#Downloading and extracting LoginMigration Zip file
Write-Host "Downloading and extracting latest LoginMigration Zip file..."
Invoke-RestMethod -Uri $ZipSource -OutFile $ZipDestination;
Expand-Archive -Path $ZipDestination -DestinationPath $BaseFolder -Force;
}
else
{
Write-Host "Installed Logins.Console.exe is the latest one...";
}
}

#Collecting data
if(('CommandLine') -contains $PSCmdlet.ParameterSetName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ Describe 'Remove-AzDataMigrationToSqlDb' {
$sourcePassword = ConvertTo-SecureString $env.TestDeleteDatabaseMigrationDb.SourceSqlConnectionPassword -AsPlainText -Force

$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

Start-TestSleep -Seconds 5
Start-Sleep -Seconds 5

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

Start-TestSleep -Seconds 5


Start-Sleep -Seconds 5
$dbMig = Get-AzDataMigrationToSqlDb -ResourceGroupName $env.TestDeleteDatabaseMigrationDb.ResourceGroupName -SqlDbInstanceName $env.TestDeleteDatabaseMigrationDb.SqlDbInstanceName -TargetDbName $env.TestDeleteDatabaseMigrationDb.TargetDbName -ErrorAction SilentlyContinue


$assert = ($dbMig -eq $null)
$assert | Should be $true
Expand Down
4 changes: 2 additions & 2 deletions src/DataMigration/DataMigration/Az.DataMigration.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 12/5/2023
# Generated on: 1/18/2024
#

@{
Expand Down Expand Up @@ -53,7 +53,7 @@ DotNetFrameworkVersion = '4.7.2'
# ProcessorArchitecture = ''

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

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = 'DataMigration.Autorest/bin/Az.DataMigration.private.dll',
Expand Down
1 change: 1 addition & 0 deletions src/DataMigration/DataMigration/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added versioning to login migration console app.

## Version 0.14.3
* Supported console app automatically upgrade.
Expand Down