mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Enable offline migration mode on sql migration extension (#16459)
This commit is contained in:
@@ -8,7 +8,7 @@ import { azureResource } from 'azureResource';
|
||||
import * as azurecore from 'azurecore';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from '../../../mssql';
|
||||
import { getAvailableManagedInstanceProducts, getAvailableStorageAccounts, getBlobContainers, getFileShares, getSqlMigrationServices, getSubscriptions, SqlMigrationService, SqlManagedInstance, startDatabaseMigration, StartDatabaseMigrationRequest, StorageAccount, getAvailableSqlVMs, SqlVMServer, getLocations, getResourceGroups, getLocationDisplayName, getSqlManagedInstanceDatabases } from '../api/azure';
|
||||
import { getAvailableManagedInstanceProducts, getAvailableStorageAccounts, getBlobContainers, getFileShares, getSqlMigrationServices, getSubscriptions, SqlMigrationService, SqlManagedInstance, startDatabaseMigration, StartDatabaseMigrationRequest, StorageAccount, getAvailableSqlVMs, SqlVMServer, getLocations, getResourceGroups, getLocationDisplayName, getSqlManagedInstanceDatabases, getBlobs } from '../api/azure';
|
||||
import { SKURecommendations } from './externalContract';
|
||||
import * as constants from '../constants/strings';
|
||||
import { MigrationLocalStorage } from './migrationLocalStorage';
|
||||
@@ -80,6 +80,7 @@ export interface Blob {
|
||||
storageAccount: StorageAccount;
|
||||
blobContainer: azureResource.BlobContainer;
|
||||
storageKey: string;
|
||||
lastBackupFile?: string; // _todo: does it make sense to store the last backup file here?
|
||||
}
|
||||
|
||||
export interface Model {
|
||||
@@ -122,6 +123,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
public _storageAccounts!: StorageAccount[];
|
||||
public _fileShares!: azureResource.FileShare[];
|
||||
public _blobContainers!: azureResource.BlobContainer[];
|
||||
public _lastFileNames!: azureResource.Blob[];
|
||||
public _refreshNetworkShareLocation!: azureResource.BlobContainer[];
|
||||
public _targetDatabaseNames!: string[];
|
||||
|
||||
@@ -739,6 +741,40 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
return this._blobContainers[index];
|
||||
}
|
||||
|
||||
public async getBlobLastBackupFileNameValues(subscription: azureResource.AzureResourceSubscription, storageAccount: StorageAccount, blobContainer: azureResource.BlobContainer): Promise<azdata.CategoryValue[]> {
|
||||
let blobLastBackupFileValues: azdata.CategoryValue[] = [];
|
||||
try {
|
||||
this._lastFileNames = await getBlobs(this._azureAccount, subscription, storageAccount, blobContainer.name);
|
||||
if (this._lastFileNames.length === 0) {
|
||||
blobLastBackupFileValues = [
|
||||
{
|
||||
displayName: constants.NO_BLOBFILES_FOUND,
|
||||
name: ''
|
||||
}
|
||||
];
|
||||
} else {
|
||||
this._lastFileNames.forEach((blob) => {
|
||||
blobLastBackupFileValues.push({
|
||||
name: blob.name,
|
||||
displayName: `${blob.name}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
blobLastBackupFileValues = [
|
||||
{
|
||||
displayName: constants.NO_BLOBFILES_FOUND,
|
||||
name: ''
|
||||
}
|
||||
];
|
||||
}
|
||||
return blobLastBackupFileValues;
|
||||
}
|
||||
|
||||
public getBlobLastBackupFileName(index: number): string {
|
||||
return this._lastFileNames[index].name;
|
||||
}
|
||||
|
||||
public async getSqlMigrationServiceValues(subscription: azureResource.AzureResourceSubscription, managedInstance: SqlManagedInstance, resourceGroupName: string): Promise<azdata.CategoryValue[]> {
|
||||
let sqlMigrationServiceValues: azdata.CategoryValue[] = [];
|
||||
@@ -797,7 +833,8 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
username: this._sqlServerUsername,
|
||||
password: this._sqlServerPassword
|
||||
},
|
||||
scope: this._targetServerInstance.id
|
||||
scope: this._targetServerInstance.id,
|
||||
autoCutoverConfiguration: {}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -815,6 +852,13 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (this._databaseBackup.migrationMode === MigrationMode.OFFLINE) {
|
||||
requestBody.properties.autoCutoverConfiguration = {
|
||||
autoCutover: (this._databaseBackup.migrationMode === MigrationMode.OFFLINE ? true : false),
|
||||
lastBackupName: this._databaseBackup.blobs[i]?.lastBackupFile
|
||||
};
|
||||
}
|
||||
break;
|
||||
case NetworkContainerType.NETWORK_SHARE:
|
||||
requestBody.properties.backupConfiguration = {
|
||||
@@ -830,6 +874,12 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (this._databaseBackup.migrationMode === MigrationMode.OFFLINE) {
|
||||
requestBody.properties.autoCutoverConfiguration = {
|
||||
autoCutover: (this._databaseBackup.migrationMode === MigrationMode.OFFLINE ? true : false)
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
requestBody.properties.sourceDatabaseName = this._migrationDbs[i];
|
||||
|
||||
Reference in New Issue
Block a user