Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
189 changes: 178 additions & 11 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@
"@fluentui/react-icons": "^2.0.265",
"@microsoft/vscode-azext-azureutils": "^4.0.1",
"@microsoft/vscode-azext-github": "^2.0.1",
"@microsoft/vscode-azext-utils": "^4.0.4",
"@microsoft/vscode-azext-utils": "file:../vscode-azuretools/utils/microsoft-vscode-azext-utils-4.0.4.tgz",
"@microsoft/vscode-azureresources-api": "^3.1.0",
"@vscode/codicons": "0.0.38",
"dayjs": "^1.11.3",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/copilot/deployWithCopilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CopilotUserInput, type IActionContext } from "@microsoft/vscode-azext-utils";
import { CopilotUserInput, type IActionContext, markAsCopilotUserInput } from "@microsoft/vscode-azext-utils";
import * as vscode from 'vscode';
import { type ContainerAppItem } from "../../tree/ContainerAppItem";
import { SharedState } from "../../webviews/OpenConfirmationViewStep";
import { deployContainerApp } from "../deployContainerApp/deployContainerApp";

export async function deployWithCopilot(context: IActionContext, node: ContainerAppItem): Promise<void> {
context.ui = new CopilotUserInput(vscode, JSON.stringify(node.viewProperties), () => SharedState.currentPanel);
markAsCopilotUserInput(context, JSON.stringify(node.viewProperties), () => SharedState.currentPanel);
await deployContainerApp(context, node);
}
12 changes: 10 additions & 2 deletions src/commands/createContainerApp/ContainerAppListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { type ContainerApp, type ContainerAppsAPIClient } from "@azure/arm-appcontainers";
import { LocationListStep, parseAzureResourceId, ResourceGroupListStep, uiUtils } from "@microsoft/vscode-azext-azureutils";
import { AzureWizardPromptStep, nonNullProp, type AzureWizardExecuteStep, type IAzureQuickPickItem, type IWizardOptions } from "@microsoft/vscode-azext-utils";
import { AzureWizardPromptStep, nonNullProp, nonNullValueAndProp, type AzureWizardExecuteStep, type ConfirmationViewProperty, type IAzureQuickPickItem, type IWizardOptions } from "@microsoft/vscode-azext-utils";
import { containerAppProvider, containerAppResourceType } from "../../constants";
import { ContainerAppItem } from "../../tree/ContainerAppItem";
import { createContainerAppsAPIClient } from "../../utils/azureClients";
Expand Down Expand Up @@ -59,6 +59,14 @@ export class ContainerAppListStep<T extends ContainerAppCreateContext> extends A
return !context.containerApp && !context.newContainerAppName;
}

public confirmationViewProperty(context: T): ConfirmationViewProperty {
return {
name: localize('containerApp', 'Container App'),
value: nonNullValueAndProp(context.containerApp, 'name'),
contextPropertyName: 'containerApp',
}
}

private async getPicks(context: T): Promise<IAzureQuickPickItem<ContainerApp>[]> {
const client: ContainerAppsAPIClient = await createContainerAppsAPIClient(context);

Expand All @@ -72,7 +80,7 @@ export class ContainerAppListStep<T extends ContainerAppCreateContext> extends A
}

if (context.managedEnvironment) {
containerApps = containerApps.filter(ca => ca.managedEnvironmentId === context.managedEnvironment.id);
containerApps = containerApps.filter(ca => ca.managedEnvironmentId === context.managedEnvironment?.id);
}

return containerApps.map(ca => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type ContainerAppsAPIClient, type ManagedEnvironment } from "@azure/arm
import { type Workspace } from "@azure/arm-operationalinsights";
import { type ResourceGroup } from "@azure/arm-resources";
import { getResourceGroupFromId, LocationListStep, ResourceGroupListStep, uiUtils } from "@microsoft/vscode-azext-azureutils";
import { AzureWizardPromptStep, nonNullProp, type AzureWizardExecuteStep, type IAzureQuickPickItem, type ISubscriptionActionContext, type IWizardOptions } from "@microsoft/vscode-azext-utils";
import { AzureWizardPromptStep, nonNullProp, nonNullValueAndProp, type AzureWizardExecuteStep, type ConfirmationViewProperty, type IAzureQuickPickItem, type ISubscriptionActionContext, type IWizardOptions } from "@microsoft/vscode-azext-utils";
import { logAnalyticsProvider, logAnalyticsResourceType, managedEnvironmentProvider, managedEnvironmentResourceType } from "../../constants";
import { createContainerAppsAPIClient } from "../../utils/azureClients";
import { localize } from "../../utils/localize";
Expand Down Expand Up @@ -57,6 +57,14 @@ export class ManagedEnvironmentListStep<T extends ManagedEnvironmentCreateContex
return !context.managedEnvironment && !context.newManagedEnvironmentName;
}

public confirmationViewProperty(context: T): ConfirmationViewProperty {
return {
name: localize('containerAppEnvironment', 'Container Apps Environment'),
value: nonNullValueAndProp(context.managedEnvironment, 'name'),
contextPropertyName: 'managedEnvironment',
};
}

private async getPicks(context: T): Promise<ManagedEnvironmentPick[]> {
const client: ContainerAppsAPIClient = await createContainerAppsAPIClient(context);

Expand Down
171 changes: 114 additions & 57 deletions src/commands/deployContainerApp/deployContainerApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
*--------------------------------------------------------------------------------------------*/

import { KnownActiveRevisionsMode } from "@azure/arm-appcontainers";
import { AzureWizard, CopilotUserInput, createSubscriptionContext, nonNullProp, type AzureWizardPromptStep, type IActionContext, type ISubscriptionActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
import { ImageSource } from "../../constants";
import { AzExtUserInput, AzureWizard, createSubscriptionContext, isCopilotUserInput, nonNullProp, type AzureWizardPromptStep, type IActionContext, type ISubscriptionActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
import { acrDomain, ImageSource, SupportedRegistries } from "../../constants";
import { type ContainerAppItem } from "../../tree/ContainerAppItem";
import { createActivityContext } from "../../utils/activityUtils";
import { isAzdExtensionInstalled } from "../../utils/azdUtils";
import { getManagedEnvironmentFromContainerApp } from "../../utils/getResourceUtils";
import { getVerifyProvidersStep } from "../../utils/getVerifyProvidersStep";
import { localize } from "../../utils/localize";
import { pickContainerApp } from "../../utils/pickItem/pickContainerApp";
import { OpenConfirmationViewStep } from "../../webviews/OpenConfirmationViewStep";
import { OpenLoadingViewStep } from "../../webviews/OpenLoadingViewStep";
import { OpenConfirmationViewStep, SharedState } from "../../webviews/OpenConfirmationViewStep";
import { openLoadingViewPanel } from "../../webviews/OpenLoadingViewStep";
import { CommandAttributes } from "../CommandAttributes";
import { ContainerAppOverwriteConfirmStep } from "../ContainerAppOverwriteConfirmStep";
import { ContainerAppListStep } from "../createContainerApp/ContainerAppListStep";
import { ManagedEnvironmentListStep } from "../createManagedEnvironment/ManagedEnvironmentListStep";
import { deployWorkspaceProject } from "../deployWorkspaceProject/deployWorkspaceProject";
import { type DeployWorkspaceProjectResults } from "../deployWorkspaceProject/getDeployWorkspaceProjectResults";
import { editContainerCommandName } from "../editContainer/editContainer";
Expand All @@ -39,62 +42,116 @@ export async function deployContainerApp(context: IActionContext, node?: Contain
throw new Error(localize('multipleContainersNotSupported', 'The container app cannot be updated using "{0}" while having more than one active container. Navigate to the specific container instance and execute "{1}" instead.', deployContainerAppCommandName, editContainerCommandName));
}

// Prompt for image source before initializing the wizard in case we need to redirect the call to 'deployWorkspaceProject' instead
const imageSource: ImageSource = await promptImageSource(subscriptionActionContext);
if (imageSource === ImageSource.RemoteAcrBuild) {
return await deployWorkspaceProject(context, item);
}

const wizardContext: ContainerAppDeployContext = {
...subscriptionActionContext,
...await createActivityContext({ withChildren: true }),
subscription: item.subscription,
containerApp: item.containerApp,
managedEnvironment: await getManagedEnvironmentFromContainerApp(subscriptionActionContext, item.containerApp),
imageSource,
activityAttributes: CommandAttributes.DeployContainerAppContainerRegistry,
};

if (isAzdExtensionInstalled()) {
wizardContext.telemetry.properties.isAzdExtensionInstalled = 'true';
}
wizardContext.telemetry.properties.revisionMode = item.containerApp.revisionsMode;

const confirmationViewTitle: string = localize('summary', 'Summary');
let confirmationViewDescription: string = localize('viewDescription', 'Please select an input you would like to change. Note: Any input proceeding the changed input will need to change as well');
let confirmationViewTabTitle: string = localize('deployContainerAppTabTitle', 'Summary - Deploy Image to Container App');
let title: string = localize('deployContainerAppTitle', 'Deploy image to container app');

const promptSteps: AzureWizardPromptStep<ContainerAppDeployContext>[] = [];
if (wizardContext.ui instanceof CopilotUserInput) {
promptSteps.push(new OpenLoadingViewStep());
confirmationViewDescription = localize('viewDescription', 'Please review AI generated inputs and select any you would like to modify. Note: Any input proceeding the modified input will need to change as well');
confirmationViewTabTitle = localize('deployContainerAppTabTitle', 'Summary - Deploy Image to Container App using Copilot');
title = localize('deployContainerAppWithCopilotTitle', 'Deploy image to container app using copilot');
let imageSource: ImageSource | undefined;
let registryDomain: SupportedRegistries | undefined;
if (isCopilotUserInput(context)) {
// If the input is coming from Copilot we want to default to Container Registry as we don't support 'deployWorkspaceProject' flow with Copilot at the moment
Comment thread
motm32 marked this conversation as resolved.
Outdated
imageSource = ImageSource.ContainerRegistry;
registryDomain = acrDomain;
} else {
// Prompt for image source before initializing the wizard in case we need to redirect the call to 'deployWorkspaceProject' instead
imageSource = await promptImageSource(subscriptionActionContext);
if (imageSource === ImageSource.RemoteAcrBuild) {
return await deployWorkspaceProject(context, item);
}
}
await deployContainerAppInternal(subscriptionActionContext, item, imageSource, registryDomain);
}

promptSteps.push(
new ContainerAppDeployStartingResourcesLogStep(),
new ImageSourceListStep(),
new ContainerAppOverwriteConfirmStep(),
new OpenConfirmationViewStep(confirmationViewTitle, confirmationViewTabTitle, confirmationViewDescription, title, () => wizard.confirmationViewProperties)
);

const wizard = new AzureWizard<ContainerAppDeployContext>(wizardContext, {
title: title,
promptSteps: promptSteps,
executeSteps: [
getVerifyProvidersStep<ContainerAppDeployContext>(),
new ContainerAppUpdateStep(),
],
});

await wizard.prompt();
wizardContext.activityTitle = localize('deployContainerAppActivityTitle', 'Deploy image to container app "{0}"', wizardContext.containerApp?.name);
await wizard.execute();

wizardContext.activityAttributes ??= {};
wizardContext.activityAttributes.azureResource = wizardContext.containerApp;
export async function deployContainerAppInternal(context: ISubscriptionActionContext, node?: ContainerAppItem, imageSource?: ImageSource, registryDomain?: SupportedRegistries): Promise<void> {
try {
if (isCopilotUserInput(context)) {
await openLoadingViewPanel(context);
}

const subscription = (context as { azureSubscription?: AzureSubscription }).azureSubscription;

if (!subscription && !node) {

@MicroFish91 Matthew Fisher (MicroFish91) Mar 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I'm understanding this correctly, could this check be consolidated to a section dedicated to Copilot flow specific changes? A brief comment noting that Copilot may sometimes fail to provide a subscription would help make the intent clearer.

// If subscription does not exist revert to regular deploy flow
context.ui = new AzExtUserInput(context);
await deployContainerApp(context);
return;
}

const promptSteps: AzureWizardPromptStep<ContainerAppDeployContext>[] = [];

if (!node) {
promptSteps.push(new ManagedEnvironmentListStep(), new ContainerAppListStep());
}

let wizardContext: ContainerAppDeployContext = {} as ContainerAppDeployContext;

if (node && imageSource) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can I get some context about this if else if here?

If you have a node and an image source, what does that imply? And if you have a subscription?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

node and image source implies you are coming from the regular flow. Just having a subscription and not those other two implies you are coming from a copilot version since we don't pass in a node in that case. I can add comments or something if that is super confusing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally, I think it'd be more readable if you had a flag that says something like: runFromCopilot that's set to true if the subscription is defined or something like that. It just makes it clearer as to why we're checking for it. Maybe add it as a flag up at L68.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 I'd love to see Copilot specific logic consolidated as much as possible to improve maintainability of the normal command flow vs. copilot command flow.

// If this command gets re run we only want the internal portion of the command to run, so we set the callbackid
context.callbackId = 'containerApps.deployContainerAppInternal';
wizardContext = {
...context,
...await createActivityContext({ withChildren: true }),
subscription: node.subscription,
containerApp: node.containerApp,
managedEnvironment: await getManagedEnvironmentFromContainerApp(context, node.containerApp),
imageSource,
registryDomain,
activityAttributes: {
...CommandAttributes.DeployContainerAppContainerRegistry,
subscription: node.subscription,
},
};

if (isAzdExtensionInstalled()) {
wizardContext.telemetry.properties.isAzdExtensionInstalled = 'true';
}
wizardContext.telemetry.properties.revisionMode = node.containerApp.revisionsMode;
} else if (subscription) {
wizardContext = {
...context,
...await createActivityContext({ withChildren: true }),
subscription: subscription,
// at the moment we are only supporting re run with container registry image source
imageSource: ImageSource.ContainerRegistry
};
}

const confirmationViewTitle: string = localize('summary', 'Summary');
let confirmationViewDescription: string = localize('viewDescription', 'Please select an input you would like to change. Note: Any input preceding the changed input will need to change as well');
let confirmationViewTabTitle: string = localize('deployContainerAppTabTitle', 'Summary - Deploy Image to Container App');
let title: string = localize('deployContainerAppTitle', 'Deploy image to container app');

if (isCopilotUserInput(wizardContext)) {
confirmationViewDescription = localize('viewDescription', 'Please review AI generated inputs and select any you would like to modify. Note: Any input preceding the modified input will need to change as well');
confirmationViewTabTitle = localize('deployContainerAppTabTitle', 'Summary - Deploy Image to Container App using Copilot');
title = localize('deployContainerAppWithCopilotTitle', 'Deploy image to container app using copilot');
}

promptSteps.push(
new ContainerAppDeployStartingResourcesLogStep(),
new ImageSourceListStep(),
new ContainerAppOverwriteConfirmStep(),
new OpenConfirmationViewStep(confirmationViewTitle, confirmationViewTabTitle, confirmationViewDescription, title, () => wizard.confirmationViewProperties)
);

const wizard = new AzureWizard<ContainerAppDeployContext>(wizardContext, {
title: title,
promptSteps: promptSteps,
executeSteps: [
getVerifyProvidersStep<ContainerAppDeployContext>(),
new ContainerAppUpdateStep(),
],
});

await wizard.prompt();
wizardContext.activityTitle = localize('deployContainerAppActivityTitle', 'Deploy image to container app "{0}"', wizardContext.containerApp?.name);
await wizard.execute();

wizardContext.activityAttributes ??= {};
wizardContext.activityAttributes.azureResource = wizardContext.containerApp;
} catch (_error) {
if (SharedState.currentPanel?.viewType === 'react-webview-loadingView') {
SharedState.currentPanel.dispose();
SharedState.currentPanel = undefined;
}
}
}

async function promptImageSource(context: ISubscriptionActionContext): Promise<ImageSource> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class ContainerAppStartVerificationStep<T extends ContainerAppStartVerifi
throw new Error(invalidName);
}

const workspaceId = context.managedEnvironment.appLogsConfiguration?.logAnalyticsConfiguration?.customerId;
const workspaceId = context.managedEnvironment?.appLogsConfiguration?.logAnalyticsConfiguration?.customerId;
if (!workspaceId) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createContainerApp } from './createContainerApp/createContainerApp';
import { createManagedEnvironment } from './createManagedEnvironment/createManagedEnvironment';
import { deleteContainerApp } from './deleteContainerApp/deleteContainerApp';
import { deleteManagedEnvironment } from './deleteManagedEnvironment/deleteManagedEnvironment';
import { deployContainerApp } from './deployContainerApp/deployContainerApp';
import { deployContainerApp, deployContainerAppInternal } from './deployContainerApp/deployContainerApp';
import { deployWorkspaceProject } from './deployWorkspaceProject/deployWorkspaceProject';
import { editContainer } from './editContainer/editContainer';
import { editContainerImage } from './editContainer/editContainerImage/editContainerImage';
Expand Down Expand Up @@ -89,6 +89,7 @@ export function registerCommands(): void {
registerCommandWithTreeNodeUnwrapping('containerApps.deployWorkspaceProject', deployWorkspaceProject);
registerCommandWithTreeNodeUnwrapping('containerApps.deployContainerApp', deployContainerApp);
registerCommandWithTreeNodeUnwrapping('containerApps.deployContainerAppWithCopilot', deployWithCopilot);
registerCommand('containerApps.deployContainerAppInternal', deployContainerAppInternal);

// github
registerCommandWithTreeNodeUnwrapping('containerApps.connectToGitHub', connectToGitHub);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { type RegistryCredentials } from "@azure/arm-appcontainers";
import { type SupportedRegistries } from "../../../constants";
import { type IContainerAppContext } from "../../IContainerAppContext";
import { type CreateAcrContext } from "../../image/imageSource/containerRegistry/acr/createAcr/CreateAcrContext";
import { type ManagedEnvironmentRequiredContext } from "../../ManagedEnvironmentContext";
import { type ManagedEnvironmentContext } from "../../ManagedEnvironmentContext";

export interface ManagedIdentityRegistryCredentialsContext extends CreateAcrContext, ManagedEnvironmentRequiredContext, IContainerAppContext {
export interface ManagedIdentityRegistryCredentialsContext extends CreateAcrContext, ManagedEnvironmentContext, IContainerAppContext {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Context loosened from ManagedEnvironmentRequiredContext → ManagedEnvironmentContext.
This is fine only if all consumers tolerate managedEnvironment being undefined. Worth a quick scan of downstream usage.

registryDomain?: SupportedRegistries;
newRegistryCredential?: RegistryCredentials;
}
Loading
Loading