Skip to content

Commit bbe4c66

Browse files
authored
Add a useManagedIdentity context to know when to disable storage (#4515)
* Try using oauth2 token for storage client * Update azure utils package * Add a useManagedIdenttiy context to know when to disable storage * Bump appservice package * Add comment
1 parent 58b0abe commit bbe4c66

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@
14121412
"@azure/storage-blob": "^12.5.0",
14131413
"@microsoft/vscode-azext-azureappservice": "^3.6.2",
14141414
"@microsoft/vscode-azext-azureappsettings": "^0.2.8",
1415-
"@microsoft/vscode-azext-azureutils": "^3.3.2",
1415+
"@microsoft/vscode-azext-azureutils": "^3.3.3",
14161416
"@microsoft/vscode-azext-utils": "^3.1.1",
14171417
"@microsoft/vscode-azureresources-api": "^2.0.4",
14181418
"cross-fetch": "^4.0.0",

src/commands/createFunctionApp/AuthenticationPromptStep.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ import { localize } from "../../localize";
1111
import { type IFunctionAppWizardContext } from "./IFunctionAppWizardContext";
1212

1313
export class AuthenticationPromptStep<T extends IFunctionAppWizardContext> extends AzureWizardPromptStep<T> {
14-
private _useManagedIdentity: boolean = false;
1514
public constructor() {
1615
super();
1716
}
1817

1918
public async prompt(context: T): Promise<void> {
2019
const options: IAzureQuickPickOptions = { placeHolder: 'Select resource authentication type', id: `AuthenticationPromptStep` };
21-
this._useManagedIdentity = (await context.ui.showQuickPick(this.getQuickPicks(context), options)).label === 'Managed identity';
20+
context.useManagedIdentity = (await context.ui.showQuickPick(this.getQuickPicks(context), options)).label === 'Managed identity';
2221
}
2322

2423
public shouldPrompt(context: T): boolean {
@@ -27,7 +26,7 @@ export class AuthenticationPromptStep<T extends IFunctionAppWizardContext> exten
2726
}
2827

2928
public async getSubWizard(context: T): Promise<IWizardOptions<T> | undefined> {
30-
if (this._useManagedIdentity) {
29+
if (context.useManagedIdentity) {
3130
const promptSteps: AzureWizardPromptStep<T>[] = [];
3231
const executeSteps: AzureWizardExecuteStep<T>[] = [];
3332
if (context.advancedCreation) {

src/commands/createFunctionApp/IFunctionAppWizardContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface IFunctionAppWizardContext extends IAppServiceWizardContext, ICr
2525
newSiteStack?: FullFunctionAppStack;
2626
durableStorageType?: DurableBackendValues;
2727
useFlexConsumptionPlan?: boolean;
28+
useManagedIdentity?: boolean;
2829

2930
// Detected local connection string
3031
hasAzureStorageConnection?: boolean;

src/tree/SubscriptionTreeItem.ts

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

66
import { type Site, type WebSiteManagementClient } from '@azure/arm-appservice';
7-
import { type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice';
87
import { SubscriptionTreeItemBase, uiUtils } from '@microsoft/vscode-azext-azureutils';
98
import { AzureWizard, parseError, type AzExtTreeItem, type IActionContext, type ICreateChildImplContext } from '@microsoft/vscode-azext-utils';
109
import { type WorkspaceFolder } from 'vscode';
10+
import { type IFunctionAppWizardContext } from '../commands/createFunctionApp/IFunctionAppWizardContext';
1111
import { createCreateFunctionAppComponents } from '../commands/createFunctionApp/createCreateFunctionAppComponents';
1212
import { projectLanguageSetting } from '../constants';
1313
import { ext } from '../extensionVariables';
@@ -87,7 +87,7 @@ export class SubscriptionTreeItem extends SubscriptionTreeItemBase {
8787
const registerProvidersTask = registerProviders(context, subscription);
8888
const { wizardContext, promptSteps, executeSteps } = await createCreateFunctionAppComponents(context, subscription.subscription, language)
8989
const title: string = localize('functionAppCreatingTitle', 'Create new Function App in Azure');
90-
const wizard: AzureWizard<IAppServiceWizardContext> = new AzureWizard(wizardContext, {
90+
const wizard: AzureWizard<IFunctionAppWizardContext> = new AzureWizard(wizardContext, {
9191
promptSteps,
9292
executeSteps,
9393
title,
@@ -99,6 +99,9 @@ export class SubscriptionTreeItem extends SubscriptionTreeItemBase {
9999
// if the providers aren't registered yet, await it here because it is required by this point
100100
await registerProvidersTask;
101101
wizardContext.activityTitle = localize('functionAppCreateActivityTitle', 'Create Function App "{0}"', nonNullProp(wizardContext, 'newSiteName'))
102+
// only disable shared key access if the user is using a managed identity and a flex consumption plan since other app service plans
103+
// and containerized function still rely on connection strings
104+
wizardContext.disableSharedKeyAccess = wizardContext.useManagedIdentity && wizardContext.useFlexConsumptionPlan;
102105
await wizard.execute();
103106

104107
let node: SlotTreeItem | ContainerTreeItem;

0 commit comments

Comments
 (0)