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

EOL warnings for V2/V3 runtimes #3771

Merged
merged 2 commits into from
Aug 2, 2023
Merged
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
10 changes: 6 additions & 4 deletions src/FuncVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ export enum FuncVersion {

export const latestGAVersion: FuncVersion = FuncVersion.v4;
export const funcVersionLink: string = 'https://aka.ms/AA1tpij';
const funcRuntimeWarningLabel: string = localize('runtimeWarning', `$(extensions-warning-message) Azure Functions runtimes v2 and v3 have reached the end of life.`);

export async function promptForFuncVersion(context: IActionContext, message?: string): Promise<FuncVersion> {
const recommended: string = localize('recommended', '(Recommended)');
let picks: IAzureQuickPickItem<FuncVersion | undefined>[] = [
{ label: 'Azure Functions v4', description: recommended, data: FuncVersion.v4 },
{ label: 'Azure Functions v3', data: FuncVersion.v3 },
{ label: 'Azure Functions v2', data: FuncVersion.v2 },
{ label: 'Azure Functions v1', data: FuncVersion.v1 }
{ label: 'Azure Functions v3', data: FuncVersion.v3, description: '$(extensions-warning-message)' },
{ label: 'Azure Functions v2', data: FuncVersion.v2, description: '$(extensions-warning-message)' },
{ label: 'Azure Functions v1', data: FuncVersion.v1 },
{ label: funcRuntimeWarningLabel, data: undefined, onPicked: () => {/*do nothing*/ } }
];

picks = picks.filter(p => osSupportsVersion(p.data));

const learnMoreQp = { label: localize('learnMore', '$(link-external) Learn more...'), description: '', data: undefined };
const learnMoreQp = { label: localize('learnMore', '$(link-external) Learn about Azure Functions versioning...'), description: '', data: undefined };
picks.push(learnMoreQp);

const options: IAzureQuickPickOptions = { placeHolder: message || localize('selectVersion', 'Select a version'), stepName: 'funcVersion', suppressPersistence: true };
Expand Down
22 changes: 15 additions & 7 deletions src/commands/createFunctionApp/stacks/FunctionAppStackStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import { setLocationsTask, SiteOSStep, WebsiteOS } from '@microsoft/vscode-azext-azureappservice';
import { AzureWizardPromptStep, IAzureQuickPickItem, IWizardOptions } from '@microsoft/vscode-azext-utils';
import { AzureWizardPromptStep, IAzureQuickPickItem, IWizardOptions, openUrl } from '@microsoft/vscode-azext-utils';
import { noRuntimeStacksAvailableLabel } from '../../../constants';
import { getMajorVersion, promptForFuncVersion } from '../../../FuncVersion';
import { localize } from '../../../localize';
import { FullFunctionAppStack, IFunctionAppWizardContext } from '../IFunctionAppWizardContext';
Expand Down Expand Up @@ -53,24 +54,31 @@ export class FunctionAppStackStep extends AzureWizardPromptStep<IFunctionAppWiza
}

private async getPicks(context: IFunctionAppWizardContext): Promise<IAzureQuickPickItem<FullFunctionAppStack | undefined>[]> {
const picks: IAzureQuickPickItem<FullFunctionAppStack | undefined>[] = await getStackPicks(context);
let picks: IAzureQuickPickItem<FullFunctionAppStack | undefined>[] = await getStackPicks(context);
if (picks.filter(p => p.label !== noRuntimeStacksAvailableLabel).length === 0) {
// if every runtime only has noRuntimeStackAvailable quickpick items, reset picks to []
picks = [];
}

const majorVersion = getMajorVersion(context.version);
const isEol = Number(majorVersion) === 2 || Number(majorVersion) === 3;
if (picks.length === 0) {
const majorVersion = getMajorVersion(context.version);
const noPicksMessage = context.stackFilter ?
localize('noStacksFoundWithFilter', '$(warning) No stacks found for "{0}" on Azure Functions v{1}', context.stackFilter, majorVersion) :
localize('noStacksFound', '$(warning) No stacks found for Azure Functions v{0}', majorVersion);
const upgradeMessage = localize('eolWarning', '$(warning) No stacks found for Azure Functions v{0} due to being EOL. Learn how to upgrade to V4...', majorVersion)
picks.push({
label: noPicksMessage,
label: isEol ? upgradeMessage : noPicksMessage,
data: undefined,
onPicked: () => {
// do nothing
onPicked: async () => {
await openUrl('https://aka.ms/function-runtime-host-warning');
}
})
}

picks.push({
label: localize('changeFuncVersion', '$(gear) Change Azure Functions version'),
description: localize('currentFuncVersion', 'Current: {0}', context.version),
description: localize('currentFuncVersion', 'Current: {0}', context.version) + (isEol ? ' $(warning)' : ''),
data: undefined,
suppressPersistence: true
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/createFunctionApp/stacks/getStackPicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createPipelineRequest } from '@azure/core-rest-pipeline';
import { AzExtPipelineResponse, createGenericClient } from '@microsoft/vscode-azext-azureutils';
import { IAzureQuickPickItem, openUrl, parseError } from '@microsoft/vscode-azext-utils';
import { FuncVersion, funcVersionLink } from '../../../FuncVersion';
import { hiddenStacksSetting } from '../../../constants';
import { hiddenStacksSetting, noRuntimeStacksAvailableLabel } from '../../../constants';
import { localize } from '../../../localize';
import { requestUtils } from '../../../utils/requestUtils';
import { getWorkspaceSetting } from '../../../vsCodeConfig/settings';
Expand Down Expand Up @@ -84,7 +84,7 @@ export async function getStackPicks(context: IFunctionAppWizardContext): Promise

if (!stackHasPicks) {
picks.push({
label: localize('noRuntimeStacksAvailable', 'No valid runtime stacks available'),
label: noRuntimeStacksAvailableLabel,
group: stack.displayText,
data: undefined
});
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,4 @@ export const functionFilter = {
};

export const sqlBindingTemplateRegex: RegExp = /Sql.*Binding/i;
export const noRuntimeStacksAvailableLabel = localize('noRuntimeStacksAvailable', 'No valid runtime stacks available');