Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding versioning to Login migration console app #23988

Merged
merged 1 commit into from
Jan 18, 2024
Merged
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 @@ -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