Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { LocationListStep, ResourceGroupListStep, VerifyProvidersStep, type ILocationWizardContext } from '@microsoft/vscode-azext-azureutils';
import { LocationListStep, VerifyProvidersStep, type ILocationWizardContext } from '@microsoft/vscode-azext-azureutils';
import { AzureWizardPromptStep, createSubscriptionContext, subscriptionExperience, type AzureWizardExecuteStep, type IWizardOptions } from '@microsoft/vscode-azext-utils';
import { type MessageItem } from 'vscode';
import { ConnectionType, SqlProvider, SqlServerResourceType } from '../../../../constants';
Expand Down Expand Up @@ -61,7 +61,6 @@ export class SqlConnectionListStep<T extends ISqlDatabaseConnectionWizardContext
LocationListStep.addProviderForFiltering(context as unknown as ILocationWizardContext, SqlProvider, SqlServerResourceType);

promptSteps.push(
new ResourceGroupListStep() as AzureWizardPromptStep<ISqlDatabaseAzureConnectionWizardContext>,
new SqlServerListStep(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { type Server, type SqlManagementClient } from '@azure/arm-sql';
import { LocationListStep, uiUtils, type ILocationWizardContext } from '@microsoft/vscode-azext-azureutils';
import { LocationListStep, ResourceGroupListStep, getResourceGroupFromId, uiUtils, type ILocationWizardContext } from '@microsoft/vscode-azext-azureutils';
import { AzureWizardPromptStep, ConfirmPreviousInputStep, nonNullProp, type AzureWizardExecuteStep, type IAzureQuickPickItem, type IWizardOptions } from '@microsoft/vscode-azext-utils';
import { localSettingsDescription } from '../../../../../constants-nls';
import { localize } from '../../../../../localize';
Expand All @@ -28,6 +28,11 @@ export class SqlServerListStep<T extends ISqlDatabaseAzureConnectionWizardContex
if (context.sqlServer?.name) {
context.valuesToMask.push(context.sqlServer.name);
}

if (context.sqlServer && !context.resourceGroup) {
const rgName: string = getResourceGroupFromId(nonNullProp(context.sqlServer, 'id'));
context.resourceGroup = { name: rgName, location: nonNullProp(context.sqlServer, 'location') };
Copy link
Copy Markdown
Contributor

@MicroFish91 MicroFish91 May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be worth pulling the actual resource and setting it here? I think that would be safer in case we ever nonNull one of the other resource properties somewhere else in the step chain as many of the "optional" properties are usually provided by the service

}
}

public shouldPrompt(context: T): boolean {
Expand All @@ -39,7 +44,7 @@ export class SqlServerListStep<T extends ISqlDatabaseAzureConnectionWizardContex
const executeSteps: AzureWizardExecuteStep<T>[] = [];

if (!context.sqlServer) {
promptSteps.push(new SqlServerNameStep(), new SqlServerUsernameAuthStep(), new SqlServerPasswordAuthStep(), new ConfirmPreviousInputStep('newSqlAdminPassword', { isPassword: true }));
promptSteps.push(new ResourceGroupListStep(), new SqlServerNameStep(), new SqlServerUsernameAuthStep(), new SqlServerPasswordAuthStep(), new ConfirmPreviousInputStep('newSqlAdminPassword', { isPassword: true }));
executeSteps.push(new SqlServerCreateStep());
LocationListStep.addStep(context, promptSteps as AzureWizardPromptStep<ILocationWizardContext>[]);
}
Expand Down