Skip to content

Commit 3b57517

Browse files
authored
Remove azureWebJobsStorage validation on deploy (#3647)
1 parent 5833940 commit 3b57517

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

src/commands/appSettings/connectionSettings/azureWebJobsStorage/validateStorageConnection.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,24 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { AzureWizard } from "@microsoft/vscode-azext-utils";
7-
import { CodeAction, ConnectionKey, localStorageEmulatorConnectionString } from "../../../../constants";
7+
import { CodeAction, ConnectionKey } from "../../../../constants";
88
import { getLocalSettingsConnectionString } from "../../../../funcConfig/local.settings";
99
import { IConnectionPromptOptions } from "../IConnectionPromptOptions";
1010
import { ISetConnectionSettingContext } from "../ISetConnectionSettingContext";
1111
import { AzureWebJobsStorageExecuteStep } from "./AzureWebJobsStorageExecuteStep";
1212
import { AzureWebJobsStoragePromptStep } from "./AzureWebJobsStoragePromptStep";
1313
import { IAzureWebJobsStorageWizardContext } from "./IAzureWebJobsStorageWizardContext";
1414

15-
// Supports validation on both 'debug' and 'deploy'
1615
export async function validateStorageConnection(context: Omit<ISetConnectionSettingContext, 'projectPath'>, projectPath: string, options?: IConnectionPromptOptions): Promise<void> {
16+
if (context.action === CodeAction.Deploy) {
17+
// Skip validation on deploy - we already connect the storage account for the user when the Function App is initially created
18+
return;
19+
}
20+
1721
const currentStorageConnection: string | undefined = await getLocalSettingsConnectionString(context, ConnectionKey.Storage, projectPath);
1822
if (currentStorageConnection) {
19-
if (context.action === CodeAction.Deploy) {
20-
if (currentStorageConnection !== localStorageEmulatorConnectionString) {
21-
// Found a valid connection in deploy mode. Set it and skip the wizard.
22-
context[ConnectionKey.Storage] = currentStorageConnection;
23-
return;
24-
}
25-
// Found an invalid connection for deploy mode, we need to proceed with acquiring a connection through the wizard...
26-
} else {
27-
// Found a valid connection in debug mode. Skip the wizard.
28-
return;
29-
}
23+
// Found a valid connection in debug mode. Skip the wizard.
24+
return;
3025
}
3126

3227
const wizardContext: IAzureWebJobsStorageWizardContext = Object.assign(context, { projectPath });

src/commands/deploy/deploy.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import type { SiteConfigResource } from '@azure/arm-appservice';
7-
import { deploy as innerDeploy, getDeployFsPath, getDeployNode, IDeployContext, IDeployPaths, showDeployConfirmation } from '@microsoft/vscode-azext-azureappservice';
7+
import { IDeployContext, IDeployPaths, getDeployFsPath, getDeployNode, deploy as innerDeploy, showDeployConfirmation } from '@microsoft/vscode-azext-azureappservice';
88
import { DialogResponses, IActionContext, nonNullValue } from '@microsoft/vscode-azext-utils';
99
import * as vscode from 'vscode';
10-
import { CodeAction, ConnectionType, deploySubpathSetting, DurableBackend, DurableBackendValues, functionFilter, ProjectLanguage, remoteBuildSetting, ScmType } from '../../constants';
10+
import { CodeAction, ConnectionType, DurableBackend, DurableBackendValues, ProjectLanguage, ScmType, deploySubpathSetting, functionFilter, remoteBuildSetting } from '../../constants';
1111
import { ext } from '../../extensionVariables';
1212
import { addLocalFuncTelemetry } from '../../funcCoreTools/getLocalFuncCoreToolsVersion';
1313
import { localize } from '../../localize';
@@ -19,9 +19,8 @@ import { isPathEqual } from '../../utils/fs';
1919
import { treeUtils } from '../../utils/treeUtils';
2020
import { getWorkspaceSetting } from '../../vsCodeConfig/settings';
2121
import { verifyInitForVSCode } from '../../vsCodeConfig/verifyInitForVSCode';
22-
import { validateStorageConnection } from '../appSettings/connectionSettings/azureWebJobsStorage/validateStorageConnection';
23-
import { validateEventHubsConnection } from '../appSettings/connectionSettings/eventHubs/validateEventHubsConnection';
2422
import { ISetConnectionSettingContext } from '../appSettings/connectionSettings/ISetConnectionSettingContext';
23+
import { validateEventHubsConnection } from '../appSettings/connectionSettings/eventHubs/validateEventHubsConnection';
2524
import { validateSqlDbConnection } from '../appSettings/connectionSettings/sqlDatabase/validateSqlDbConnection';
2625
import { tryGetFunctionProjectRoot } from '../createNewProject/verifyIsProject';
2726
import { notifyDeployComplete } from './notifyDeployComplete';
@@ -97,12 +96,9 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |
9796
const durableStorageType: DurableBackendValues | undefined = await durableUtils.getStorageTypeFromWorkspace(language, context.projectPath);
9897
context.telemetry.properties.projectDurableStorageType = durableStorageType;
9998

100-
const { shouldValidateStorage, shouldValidateEventHubs, shouldValidateSqlDb } = await shouldValidateConnections(durableStorageType, client, context.projectPath);
99+
const { shouldValidateEventHubs, shouldValidateSqlDb } = await shouldValidateConnections(durableStorageType, client, context.projectPath);
101100

102101
// Preliminary local validation done to ensure all required resources have been created and are available. Final deploy writes are made in 'verifyAppSettings'
103-
if (shouldValidateStorage) {
104-
await validateStorageConnection(context, context.projectPath, { preselectedConnectionType: ConnectionType.Azure });
105-
}
106102
if (shouldValidateEventHubs) {
107103
await validateEventHubsConnection(context, context.projectPath, { preselectedConnectionType: ConnectionType.Azure });
108104
}

src/commands/deploy/shouldValidateConnection.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@ import { ConnectionKey, DurableBackend, DurableBackendValues } from "../../const
44
import { getEventHubName } from "../appSettings/connectionSettings/eventHubs/validateEventHubsConnection";
55

66
export interface IShouldValidateConnection {
7-
shouldValidateStorage: boolean;
87
shouldValidateEventHubs: boolean;
98
shouldValidateSqlDb: boolean;
109
}
1110

1211
export async function shouldValidateConnections(durableStorageType: DurableBackendValues | undefined, client: SiteClient, projectPath: string): Promise<IShouldValidateConnection> {
1312
const app: StringDictionary = await client.listApplicationSettings();
14-
const remoteStorageConnection: string | undefined = app?.properties?.[ConnectionKey.Storage];
1513
const remoteEventHubsConnection: string | undefined = app?.properties?.[ConnectionKey.EventHubs];
1614
const remoteSqlDbConnection: string | undefined = app?.properties?.[ConnectionKey.SQL];
1715
const eventHubName: string | undefined = await getEventHubName(projectPath);
1816

19-
const shouldValidateStorage: boolean = !remoteStorageConnection;
2017
const shouldValidateEventHubs: boolean = durableStorageType === DurableBackend.Netherite && (!eventHubName || !remoteEventHubsConnection);
2118
const shouldValidateSqlDb: boolean = durableStorageType === DurableBackend.SQL && !remoteSqlDbConnection;
22-
return { shouldValidateStorage, shouldValidateEventHubs, shouldValidateSqlDb };
19+
return { shouldValidateEventHubs, shouldValidateSqlDb };
2320
}

0 commit comments

Comments
 (0)