Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
30 changes: 29 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
"category": "Azure Container Apps",
"icon": "$(add)"
},
{
"command": "containerApps.createContainerAppFromWorkspace",
"title": "%containerApps.createContainerAppFromWorkspace%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.deleteManagedEnvironment",
"title": "%containerApps.deleteManagedEnvironment%",
Expand All @@ -91,6 +96,11 @@
"title": "%containerApps.deployWorkspaceProject%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.deployWorkspaceProjectToContainerApp",
"title": "%containerApps.deployWorkspaceProjectToContainerApp%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.deleteContainerApp",
"title": "%containerApps.deleteContainerApp%",
Expand Down Expand Up @@ -279,6 +289,11 @@
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /managedEnvironmentItem/i",
"group": "2@1"
},
{
"command": "containerApps.createContainerAppFromWorkspace",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /managedEnvironmentItem/i",
"group": "2@2"
Comment thread
nturinski marked this conversation as resolved.
},
{
"command": "containerApps.deleteManagedEnvironment",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /managedEnvironmentItem/i",
Expand Down Expand Up @@ -329,10 +344,15 @@
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem(.*)revisionMode:single/i",
"group": "4@1"
},
{
"command": "containerApps.deployWorkspaceProjectToContainerApp",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem/i",
"group": "5@2"
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
},
{
"command": "containerApps.deleteContainerApp",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /containerAppItem/i",
"group": "5@1"
"group": "5@2"
},
{
"command": "containerApps.deployImage",
Expand Down Expand Up @@ -471,6 +491,14 @@
}
],
"commandPalette": [
{
"command": "containerApps.createContainerAppFromWorkspace",
"when": "never"
},
{
"command": "containerApps.deployWorkspaceProjectToContainerApp",
"when": "never"
},
{
"command": "containerApps.deployImageApi",
"when": "never"
Expand Down
4 changes: 3 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"containerApps.enableOutputTimestamps": "Prepends each line displayed in the output channel with a timestamp.",
"containerApps.browse": "Browse",
"containerApps.createContainerApp": "Create Container App...",
"containerApps.createContainerAppFromWorkspace": "Create Container App from Workspace...",
"containerApps.editContainerApp": "Edit Container App (Advanced)...",
"containerApps.deployImage": "Update Container App Image...",
"containerApps.deployImageApi": "Update Container App Image (API)...",
"containerApps.deployWorkspaceProject": "Deploy Project from Workspace...",
"containerApps.deployWorkspaceProject": "Deploy Workspace Project...",
"containerApps.deployWorkspaceProjectToContainerApp": "Deploy Workspace Project (Container App)...",
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
"containerApps.deleteContainerApp": "Delete Container App...",
"containerApps.disableIngress": "Disable Ingress for Container App",
"containerApps.enableIngress": "Enable Ingress for Container App...",
Expand Down
3 changes: 0 additions & 3 deletions src/commands/deployWorkspaceProject/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import type { AzureSubscription } from "@microsoft/vscode-azureresources-api";
import { ProgressLocation, window } from "vscode";
import { activityInfoIcon, activitySuccessContext, appProvider, managedEnvironmentsId, operationalInsightsProvider, webProvider } from "../../constants";
import { ext } from "../../extensionVariables";
import { ContainerAppModel, isIngressEnabled } from "../../tree/ContainerAppItem";
import { ContainerAppItem, ContainerAppModel, isIngressEnabled } from "../../tree/ContainerAppItem";
import { ManagedEnvironmentItem } from "../../tree/ManagedEnvironmentItem";
import { createActivityChildContext, createActivityContext } from "../../utils/activity/activityUtils";
import { localize } from "../../utils/localize";
import { browseContainerApp } from "../browseContainerApp";
Expand All @@ -27,7 +28,7 @@ import { ShouldSaveDeploySettingsPromptStep } from "./ShouldSaveDeploySettingsPr
import { DefaultResourcesNameStep } from "./getDefaultValues/DefaultResourcesNameStep";
import { getDefaultContextValues } from "./getDefaultValues/getDefaultContextValues";

export async function deployWorkspaceProject(context: IActionContext): Promise<void> {
export async function deployWorkspaceProject(context: IActionContext, item?: ContainerAppItem | ManagedEnvironmentItem): Promise<void> {
ext.outputChannel.appendLog(localize('beginCommandExecution', '--------Initializing deploy workspace project--------'));

const subscription: AzureSubscription = await subscriptionExperience(context, ext.rgApiV2.resources.azureResourceTreeDataProvider);
Expand All @@ -40,7 +41,7 @@ export async function deployWorkspaceProject(context: IActionContext): Promise<v
cancellable: false,
title: localize('loadingWorkspaceTitle', 'Loading workspace project deployment configurations...')
}, async () => {
defaultContextValues = await getDefaultContextValues({ ...context, ...subscriptionContext });
defaultContextValues = await getDefaultContextValues({ ...context, ...subscriptionContext }, item);
});

const wizardContext: DeployWorkspaceProjectContext = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface DeployWorkspaceProjectSettings {
containerRegistryName?: string;
}

const deployWorkspaceProjectPrefix: string = 'deployWorkspaceProject';
export const deployWorkspaceProjectPrefix: string = 'deployWorkspaceProject';

export async function getDeployWorkspaceProjectSettings(rootFolder: WorkspaceFolder): Promise<DeployWorkspaceProjectSettings> {
const settingsPath: string = settingUtils.getDefaultRootWorkspaceSettingsPath(rootFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DefaultResourcesNameStep extends AzureWizardPromptStep<DeployWorksp
);

const resourceBaseName: string = (await context.ui.showInputBox({
prompt: localize('resourceBaseNamePrompt', 'Enter a name for new container app resources.'),
prompt: localize('resourceBaseNamePrompt', 'Enter a name for the new container app resource(s).'),
validateInput: this.validateInput,
asyncValidationTask: (name: string) => this.validateNameAvailability(context, name)
})).trim();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { ManagedEnvironment } from "@azure/arm-appcontainers";
import type { ResourceGroup } from "@azure/arm-resources";
import { type ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { ContainerAppItem, ContainerAppModel } from "../../../../tree/ContainerAppItem";
import { ManagedEnvironmentItem } from "../../../../tree/ManagedEnvironmentItem";
import type { DeployWorkspaceProjectSettings } from "../../deployWorkspaceProjectSettings";
import { getContainerAppResourcesFromItem, getContainerAppResourcesFromSettings } from "./getDefaultResourcesFrom";
import { promptForEnvironmentResources } from "./promptForEnvironmentResources";

export interface DefaultContainerAppsResources {
resourceGroup?: ResourceGroup;
managedEnvironment?: ManagedEnvironment;
containerApp?: ContainerAppModel;
}

export async function getDefaultContainerAppsResources(
context: ISubscriptionActionContext,
settings: DeployWorkspaceProjectSettings | undefined,
item?: ContainerAppItem | ManagedEnvironmentItem
): Promise<DefaultContainerAppsResources> {
// Try to obtain container app resources using any saved workspace settings
const { resourceGroup, managedEnvironment, containerApp } = await getContainerAppResourcesFromSettings(context, settings);
Comment thread
MicroFish91 marked this conversation as resolved.
if (resourceGroup && managedEnvironment && containerApp) {
return { resourceGroup, managedEnvironment, containerApp };
}

// If a tree item is provided that can be used to deduce default context values, use those, otherwise prompt for an environment
if (item) {
return await getContainerAppResourcesFromItem(context, item);
} else {
return await promptForEnvironmentResources(context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ContainerApp, ContainerAppsAPIClient } from "@azure/arm-appcontainers";
import type { ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { ext } from "../../../../extensionVariables";
import { ContainerAppItem, ContainerAppModel } from "../../../../tree/ContainerAppItem";
import { ManagedEnvironmentItem } from "../../../../tree/ManagedEnvironmentItem";
import { createContainerAppsAPIClient } from "../../../../utils/azureClients";
import { localize } from "../../../../utils/localize";
import type { DeployWorkspaceProjectSettings } from "../../deployWorkspaceProjectSettings";
import type { DefaultContainerAppsResources } from "./getDefaultContainerAppsResources";
import { getResourcesFromContainerAppHelper, getResourcesFromManagedEnvironmentHelper } from "./getResourceHelpers";

const noMatchingResources = {
resourceGroup: undefined,
managedEnvironment: undefined,
containerApp: undefined
};

export async function getContainerAppResourcesFromSettings(context: ISubscriptionActionContext, settings: DeployWorkspaceProjectSettings | undefined): Promise<DefaultContainerAppsResources> {
if (!settings || !settings.containerAppResourceGroupName || !settings.containerAppName) {
Comment thread
MicroFish91 marked this conversation as resolved.
return noMatchingResources;
}

const resourceGroupName: string = settings.containerAppResourceGroupName;
const containerAppName: string = settings.containerAppName;

try {
const client: ContainerAppsAPIClient = await createContainerAppsAPIClient(context);
const containerApp: ContainerApp = await client.containerApps.get(resourceGroupName, containerAppName);
const containerAppModel: ContainerAppModel = ContainerAppItem.CreateContainerAppModel(containerApp);

const resources: DefaultContainerAppsResources = await getResourcesFromContainerAppHelper(context, containerAppModel);
ext.outputChannel.appendLog(localize('foundResourceMatch', 'Used saved workspace settings and found existing container app resources.'));

return resources;
} catch {
ext.outputChannel.appendLog(localize('noResourceMatch', 'Used saved workspace settings to search for container app "{0}" in resource group "{1}" but found no match.', settings.containerAppName, settings.containerAppResourceGroupName));
return noMatchingResources;
}
}

export async function getContainerAppResourcesFromItem(context: ISubscriptionActionContext, item: ContainerAppItem | ManagedEnvironmentItem): Promise<DefaultContainerAppsResources> {
Comment thread
MicroFish91 marked this conversation as resolved.
if (!ContainerAppItem.isContainerAppItem(item) && !ManagedEnvironmentItem.isManagedEnvironmentItem(item)) {
const incompatibleMessage: string = localize('incompatibleTreeItem', 'An incompatible Azure Container Apps tree item was provided for project deployment.');
ext.outputChannel.appendLog(localize('incompatibleMessageLog', 'Error: {0}', incompatibleMessage));
throw new Error(incompatibleMessage);
}

if (ContainerAppItem.isContainerAppItem(item)) {
Comment thread
MicroFish91 marked this conversation as resolved.
return await getResourcesFromContainerAppHelper(context, item.containerApp);
} else {
return await getResourcesFromManagedEnvironmentHelper(context, item.managedEnvironment);
}
}
Loading