mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
@@ -263,27 +263,27 @@ export async function startDatabaseMigration(account: azdata.Account, subscripti
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDatabaseMigration(account: azdata.Account, subscription: Subscription, regionName: string, migrationId: string, sessionId: string): Promise<DatabaseMigration> {
|
export async function getMigrationStatus(account: azdata.Account, subscription: Subscription, migration: DatabaseMigration, sessionId: string, asyncUrl: string): Promise<DatabaseMigration> {
|
||||||
const api = await getAzureCoreAPI();
|
const api = await getAzureCoreAPI();
|
||||||
const path = `${migrationId}?api-version=2020-09-01-preview`;
|
const migrationOperationId = getMigrationOperationId(migration, asyncUrl);
|
||||||
|
const path = `${migration.id}?migrationOperationId=${migrationOperationId}&$expand=MigrationStatusDetails&api-version=2020-09-01-preview`;
|
||||||
const response = await api.makeAzureRestRequest(account, subscription, path, azurecore.HttpRequestMethod.GET, undefined, true, undefined, getSessionIdHeader(sessionId));
|
const response = await api.makeAzureRestRequest(account, subscription, path, azurecore.HttpRequestMethod.GET, undefined, true, undefined, getSessionIdHeader(sessionId));
|
||||||
if (response.errors.length > 0) {
|
if (response.errors.length > 0) {
|
||||||
if (response.response.status === 404 && response.response.data.error.code === 'ResourceDoesNotExist') {
|
|
||||||
throw new Error(response.response.data.error.code);
|
|
||||||
}
|
|
||||||
throw new Error(response.errors.toString());
|
throw new Error(response.errors.toString());
|
||||||
}
|
}
|
||||||
return response.response.data;
|
return response.response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMigrationStatus(account: azdata.Account, subscription: Subscription, migration: DatabaseMigration, sessionId: string): Promise<DatabaseMigration> {
|
function getMigrationOperationId(migration: DatabaseMigration, asyncUrl: string): string {
|
||||||
const api = await getAzureCoreAPI();
|
// migrationOperationId may be undefined when provisioning has failed
|
||||||
const path = `${migration.id}?$expand=MigrationStatusDetails&api-version=2020-09-01-preview`;
|
// fall back to the operationId from the asyncUrl in the create migration response
|
||||||
const response = await api.makeAzureRestRequest(account, subscription, path, azurecore.HttpRequestMethod.GET, undefined, true, undefined, getSessionIdHeader(sessionId));
|
if (migration.properties.migrationOperationId) {
|
||||||
if (response.errors.length > 0) {
|
return migration.properties.migrationOperationId;
|
||||||
throw new Error(response.errors.toString());
|
|
||||||
}
|
}
|
||||||
return response.response.data;
|
|
||||||
|
return asyncUrl
|
||||||
|
? vscode.Uri.parse(asyncUrl)?.path?.split('/').reverse()[0]
|
||||||
|
: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMigrationAsyncOperationDetails(account: azdata.Account, subscription: Subscription, url: string, sessionId: string): Promise<AzureAsyncOperationResource> {
|
export async function getMigrationAsyncOperationDetails(account: azdata.Account, subscription: Subscription, url: string, sessionId: string): Promise<AzureAsyncOperationResource> {
|
||||||
@@ -436,6 +436,7 @@ export interface DatabaseMigration {
|
|||||||
export interface DatabaseMigrationProperties {
|
export interface DatabaseMigrationProperties {
|
||||||
scope: string;
|
scope: string;
|
||||||
provisioningState: 'Succeeded' | 'Failed' | 'Creating';
|
provisioningState: 'Succeeded' | 'Failed' | 'Creating';
|
||||||
|
provisioningError: string;
|
||||||
migrationStatus: 'InProgress' | 'Failed' | 'Succeeded' | 'Creating' | 'Completing' | 'Canceling';
|
migrationStatus: 'InProgress' | 'Failed' | 'Succeeded' | 'Creating' | 'Completing' | 'Canceling';
|
||||||
migrationStatusDetails?: MigrationStatusDetails;
|
migrationStatusDetails?: MigrationStatusDetails;
|
||||||
startedOn: string;
|
startedOn: string;
|
||||||
|
|||||||
@@ -492,11 +492,16 @@ export class MigrationCutoverDialog {
|
|||||||
await this._model.fetchStatus();
|
await this._model.fetchStatus();
|
||||||
const errors = [];
|
const errors = [];
|
||||||
errors.push(this._model.migrationOpStatus.error?.message);
|
errors.push(this._model.migrationOpStatus.error?.message);
|
||||||
|
errors.push(this._model._migration.asyncOperationResult?.error?.message);
|
||||||
|
errors.push(this._model.migrationStatus.properties.provisioningError);
|
||||||
errors.push(this._model.migrationStatus.properties.migrationFailureError?.message);
|
errors.push(this._model.migrationStatus.properties.migrationFailureError?.message);
|
||||||
errors.push(this._model.migrationStatus.properties.migrationStatusDetails?.fileUploadBlockingErrors ?? []);
|
errors.push(this._model.migrationStatus.properties.migrationStatusDetails?.fileUploadBlockingErrors ?? []);
|
||||||
errors.push(this._model.migrationStatus.properties.migrationStatusDetails?.restoreBlockingReason);
|
errors.push(this._model.migrationStatus.properties.migrationStatusDetails?.restoreBlockingReason);
|
||||||
this._dialogObject.message = {
|
this._dialogObject.message = {
|
||||||
text: errors.filter(e => e !== undefined).join(EOL),
|
// remove undefined and duplicate error entries
|
||||||
|
text: errors
|
||||||
|
.filter((e, i, arr) => e !== undefined && i === arr.indexOf(e))
|
||||||
|
.join(EOL),
|
||||||
level: this._model.migrationStatus.properties.migrationStatus === MigrationStatus.InProgress
|
level: this._model.migrationStatus.properties.migrationStatus === MigrationStatus.InProgress
|
||||||
|| this._model.migrationStatus.properties.migrationStatus === MigrationStatus.Completing
|
|| this._model.migrationStatus.properties.migrationStatus === MigrationStatus.Completing
|
||||||
? azdata.window.MessageLevel.Warning
|
? azdata.window.MessageLevel.Warning
|
||||||
@@ -566,9 +571,12 @@ export class MigrationCutoverDialog {
|
|||||||
const isBlobMigration = this._model.isBlobMigration();
|
const isBlobMigration = this._model.isBlobMigration();
|
||||||
// Displaying storage accounts and blob container for azure blob backups.
|
// Displaying storage accounts and blob container for azure blob backups.
|
||||||
if (isBlobMigration) {
|
if (isBlobMigration) {
|
||||||
backupLocation = `${this._model._migration.migrationContext.properties.backupConfiguration.sourceLocation?.azureBlob?.storageAccountResourceId.split('/').pop()} - ${this._model._migration.migrationContext.properties.backupConfiguration.sourceLocation?.azureBlob?.blobContainerName}`;
|
const storageAccountResourceId = this._model._migration.migrationContext.properties.backupConfiguration?.sourceLocation?.azureBlob?.storageAccountResourceId;
|
||||||
|
const blobContainerName = this._model._migration.migrationContext.properties.backupConfiguration?.sourceLocation?.azureBlob?.blobContainerName;
|
||||||
|
backupLocation = `${storageAccountResourceId?.split('/').pop()} - ${blobContainerName}`;
|
||||||
} else {
|
} else {
|
||||||
backupLocation = this._model._migration.migrationContext.properties.backupConfiguration?.sourceLocation?.fileShare?.path! ?? '-';
|
const fileShare = this._model._migration.migrationContext.properties.backupConfiguration?.sourceLocation?.fileShare;
|
||||||
|
backupLocation = fileShare?.path! ?? '-';
|
||||||
}
|
}
|
||||||
this._backupLocationInfoField.text.value = backupLocation ?? '-';
|
this._backupLocationInfoField.text.value = backupLocation ?? '-';
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export class MigrationCutoverDialogModel {
|
|||||||
this._migration.subscription,
|
this._migration.subscription,
|
||||||
this._migration.migrationContext,
|
this._migration.migrationContext,
|
||||||
this._migration.sessionId!,
|
this._migration.sessionId!,
|
||||||
|
this._migration.asyncUrl
|
||||||
));
|
));
|
||||||
|
|
||||||
sendSqlMigrationActionEvent(
|
sendSqlMigrationActionEvent(
|
||||||
@@ -98,7 +99,7 @@ export class MigrationCutoverDialogModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isBlobMigration(): boolean {
|
public isBlobMigration(): boolean {
|
||||||
return this._migration.migrationContext.properties.backupConfiguration.sourceLocation?.azureBlob !== undefined;
|
return this._migration.migrationContext.properties.backupConfiguration?.sourceLocation?.azureBlob !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public confirmCutoverStepsString(): string {
|
public confirmCutoverStepsString(): string {
|
||||||
|
|||||||
@@ -32,14 +32,6 @@ export class MigrationLocalStorage {
|
|||||||
|
|
||||||
await this.refreshMigrationAzureAccount(migration);
|
await this.refreshMigrationAzureAccount(migration);
|
||||||
|
|
||||||
migration.migrationContext = await getMigrationStatus(
|
|
||||||
migration.azureAccount,
|
|
||||||
migration.subscription,
|
|
||||||
migration.migrationContext,
|
|
||||||
migration.sessionId!
|
|
||||||
);
|
|
||||||
migration.migrationContext.properties.sourceDatabaseName = sourceDatabase;
|
|
||||||
migration.migrationContext.properties.backupConfiguration = backupConfiguration;
|
|
||||||
if (migration.asyncUrl) {
|
if (migration.asyncUrl) {
|
||||||
migration.asyncOperationResult = await getMigrationAsyncOperationDetails(
|
migration.asyncOperationResult = await getMigrationAsyncOperationDetails(
|
||||||
migration.azureAccount,
|
migration.azureAccount,
|
||||||
@@ -47,6 +39,17 @@ export class MigrationLocalStorage {
|
|||||||
migration.asyncUrl,
|
migration.asyncUrl,
|
||||||
migration.sessionId!
|
migration.sessionId!
|
||||||
);
|
);
|
||||||
|
|
||||||
|
migration.migrationContext = await getMigrationStatus(
|
||||||
|
migration.azureAccount,
|
||||||
|
migration.subscription,
|
||||||
|
migration.migrationContext,
|
||||||
|
migration.sessionId!,
|
||||||
|
migration.asyncUrl
|
||||||
|
);
|
||||||
|
|
||||||
|
migration.migrationContext.properties.sourceDatabaseName = sourceDatabase;
|
||||||
|
migration.migrationContext.properties.backupConfiguration = backupConfiguration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user