Skip to content

Commit 4b5ef5c

Browse files
authored
Add Basic and Advanced flow for Deploy Workspace Project (#961)
1 parent 257c837 commit 4b5ef5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+766
-589
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,9 @@
862862
"@azure/storage-blob": "^12.4.1",
863863
"@fluentui/react-components": "^9.56.2",
864864
"@fluentui/react-icons": "^2.0.265",
865-
"@microsoft/vscode-azext-azureutils": "^3.3.3",
865+
"@microsoft/vscode-azext-azureutils": "^3.5.0",
866866
"@microsoft/vscode-azext-github": "^1.0.4",
867-
"@microsoft/vscode-azext-utils": "^3.3.3",
867+
"@microsoft/vscode-azext-utils": "^3.4.0",
868868
"@microsoft/vscode-azureresources-api": "^2.0.2",
869869
"@vscode/codicons": "0.0.38",
870870
"buffer": "^6.0.3",

src/commands/ManagedEnvironmentContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ export interface ManagedEnvironmentRequiredContext extends ISubscriptionActionCo
1111
subscription: AzureSubscription;
1212
managedEnvironment: ManagedEnvironment;
1313
}
14+
15+
export interface ManagedEnvironmentContext extends ISubscriptionActionContext {
16+
subscription: AzureSubscription;
17+
managedEnvironment?: ManagedEnvironment;
18+
}

src/commands/StartingResourcesLogStep.ts

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { type ContainerApp, type ManagedEnvironment } from "@azure/arm-appcontainers";
7+
import { type Registry } from "@azure/arm-containerregistry";
78
import { type ResourceGroup } from "@azure/arm-resources";
89
import { LocationListStep, type ILocationWizardContext } from "@microsoft/vscode-azext-azureutils";
9-
import { ActivityChildItem, ActivityChildType, activityInfoIcon, AzureWizardPromptStep, createContextValue, type ExecuteActivityContext, type IActionContext } from "@microsoft/vscode-azext-utils";
10+
import { ActivityChildItem, ActivityChildType, activityInfoIcon, AzureWizardPromptStep, createContextValue, prependOrInsertAfterLastInfoChild, type ActivityInfoChild, type ExecuteActivityContext, type IActionContext } from "@microsoft/vscode-azext-utils";
1011
import { activityInfoContext } from "../constants";
1112
import { ext } from "../extensionVariables";
12-
import { prependOrInsertAfterLastInfoChild } from "../utils/activityUtils";
1313
import { localize } from "../utils/localize";
1414

1515
type StartingResourcesLogContext = IActionContext & Partial<ExecuteActivityContext> & ILocationWizardContext & {
1616
resourceGroup?: ResourceGroup,
1717
managedEnvironment?: ManagedEnvironment,
18+
registry?: Registry;
1819
containerApp?: ContainerApp
1920
};
2021

@@ -26,17 +27,13 @@ const startingResourcesContext: string = 'startingResourcesLogStepItem';
2627
*/
2728
export class StartingResourcesLogStep<T extends StartingResourcesLogContext> extends AzureWizardPromptStep<T> {
2829
public hideStepCount: boolean = true;
29-
protected hasLogged: boolean = false;
3030

3131
/**
3232
* Implement if you require additional context loading before resource logging
3333
*/
3434
protected configureStartingResources?(context: T): void | Promise<void>;
3535

3636
public async configureBeforePrompt(context: T): Promise<void> {
37-
if (this.hasLogged) {
38-
return;
39-
}
4037
await this.configureStartingResources?.(context);
4138
await this.logStartingResources(context);
4239
}
@@ -50,47 +47,71 @@ export class StartingResourcesLogStep<T extends StartingResourcesLogContext> ext
5047
}
5148

5249
protected async logStartingResources(context: T): Promise<void> {
50+
// Resource group
5351
if (context.resourceGroup) {
5452
prependOrInsertAfterLastInfoChild(context,
5553
new ActivityChildItem({
5654
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
5755
label: localize('useResourceGroup', 'Use resource group "{0}"', context.resourceGroup.name),
5856
activityType: ActivityChildType.Info,
59-
iconPath: activityInfoIcon
60-
})
57+
iconPath: activityInfoIcon,
58+
stepId: this.id,
59+
}) as ActivityInfoChild,
6160
);
6261
ext.outputChannel.appendLog(localize('usingResourceGroup', 'Using resource group "{0}".', context.resourceGroup.name));
6362
}
63+
context.telemetry.properties.existingResourceGroup = String(!!context.resourceGroup);
6464

65+
// Managed environment
6566
if (context.managedEnvironment) {
6667
prependOrInsertAfterLastInfoChild(context,
6768
new ActivityChildItem({
6869
label: localize('useManagedEnvironment', 'Use managed environment "{0}"', context.managedEnvironment.name),
6970
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
7071
activityType: ActivityChildType.Info,
71-
iconPath: activityInfoIcon
72-
}),
72+
iconPath: activityInfoIcon,
73+
stepId: this.id,
74+
}) as ActivityInfoChild,
7375
);
7476
ext.outputChannel.appendLog(localize('usingManagedEnvironment', 'Using managed environment "{0}".', context.managedEnvironment.name));
7577
}
78+
context.telemetry.properties.existingEnvironment = String(!!context.managedEnvironment);
79+
80+
// Container registry
81+
if (context.registry) {
82+
prependOrInsertAfterLastInfoChild(context,
83+
new ActivityChildItem({
84+
label: localize('useAcr', 'Use container registry "{0}"', context.registry.name),
85+
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
86+
activityType: ActivityChildType.Info,
87+
iconPath: activityInfoIcon,
88+
stepId: this.id,
89+
}) as ActivityInfoChild,
90+
);
91+
ext.outputChannel.appendLog(localize('usingAcr', 'Using Azure Container Registry "{0}".', context.registry.name));
92+
}
93+
context.telemetry.properties.existingRegistry = String(!!context.registry);
7694

95+
// Container app
7796
if (context.containerApp) {
7897
prependOrInsertAfterLastInfoChild(context,
7998
new ActivityChildItem({
8099
label: localize('useContainerApp', 'Use container app "{0}"', context.containerApp.name),
81100
contextValue: createContextValue([startingResourcesContext, activityInfoContext]),
82101
activityType: ActivityChildType.Info,
83102
iconPath: activityInfoIcon,
84-
}),
103+
stepId: this.id,
104+
}) as ActivityInfoChild,
85105
);
86106
ext.outputChannel.appendLog(localize('usingContainerApp', 'Using container app "{0}".', context.containerApp.name));
87107
}
108+
context.telemetry.properties.existingContainerApp = String(!!context.containerApp);
88109

110+
// Location
89111
if (LocationListStep.hasLocation(context)) {
90112
const location: string = (await LocationListStep.getLocation(context)).name;
91113
ext.outputChannel.appendLog(localize('usingLocation', 'Using location: "{0}".', location));
92114
}
93-
94-
this.hasLogged = true;
115+
context.telemetry.properties.existingLocation = String(!!LocationListStep.hasLocation(context));
95116
}
96117
}

src/commands/api/CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Change Log
22

3-
### 0.0.3
3+
## 1.0.0
4+
### Changed
5+
* [[961](https://github.com/microsoft/vscode-azurecontainerapps/pull/961)] Add a new resource location parameter to the `deployWorkspaceProjectApi` definition. If no location is provided, try to infer location via other provided resources.
6+
* [[961](https://github.com/microsoft/vscode-azurecontainerapps/pull/961)] Suppress registry prompting by default and remove associated flag (`suppressRegistryPrompt`)
47

8+
## 0.0.3
59
### Added
610
* [[817]](https://github.com/microsoft/vscode-azurecontainerapps/pull/817) Added an API entry-point and compat wrapper for existing `deployImageApi` command
711

812
### Changed
913
* [[816]](https://github.com/microsoft/vscode-azurecontainerapps/pull/816) Added backward compatibility to ensure existing functionality remains unaffected by new managed identity features.
1014

11-
### 0.0.2
12-
15+
## 0.0.2
1316
### Changed
1417
* [[615]](https://github.com/microsoft/vscode-azurecontainerapps/pull/615) Removed ability to set option `ignoreExistingDeploySettings`. This will now happen automatically by default.
1518

1619
## 0.0.1
17-
* Initial release
18-
1920
### Added
2021
* [[578]](https://github.com/microsoft/vscode-azurecontainerapps/pull/578) Added an API entry-point to the `deployWorkspaceProject` command

src/commands/api/deployWorkspaceProjectApi.ts

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

66
import { type ResourceGroup } from "@azure/arm-resources";
7-
import { ResourceGroupListStep, parseAzureResourceGroupId } from "@microsoft/vscode-azext-azureutils";
8-
import { callWithTelemetryAndErrorHandling, createSubscriptionContext, subscriptionExperience, type IActionContext, type ISubscriptionActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
7+
import { LocationListStep, ResourceGroupListStep, parseAzureResourceGroupId } from "@microsoft/vscode-azext-azureutils";
8+
import { callWithTelemetryAndErrorHandling, createSubscriptionContext, nonNullValueAndProp, subscriptionExperience, type IActionContext, type ISubscriptionActionContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
99
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
1010
import { Uri, type WorkspaceFolder } from "vscode";
1111
import { ext } from "../../extensionVariables";
@@ -22,10 +22,10 @@ export async function deployWorkspaceProjectApi(deployWorkspaceProjectOptions: a
2222
return await callWithTelemetryAndErrorHandling('containerApps.api.deployWorkspaceProject', async (context: IActionContext): Promise<DeployWorkspaceProjectResults> => {
2323
const {
2424
resourceGroupId,
25+
location,
2526
rootPath,
2627
dockerfilePath,
2728
srcPath,
28-
suppressRegistryPrompt,
2929
suppressConfirmation,
3030
suppressContainerAppCreation,
3131
shouldSaveDeploySettings
@@ -52,10 +52,15 @@ export async function deployWorkspaceProjectApi(deployWorkspaceProjectOptions: a
5252
shouldSaveDeploySettings: !!shouldSaveDeploySettings,
5353
});
5454

55+
if (location || deployWorkspaceProjectInternalContext.resourceGroup) {
56+
const autoSelectLocation = location ?? nonNullValueAndProp(deployWorkspaceProjectInternalContext.resourceGroup, 'location');
57+
await LocationListStep.setAutoSelectLocation(deployWorkspaceProjectInternalContext, autoSelectLocation);
58+
}
59+
5560
const deployWorkspaceProjectContext: DeployWorkspaceProjectContext = await deployWorkspaceProjectInternal(deployWorkspaceProjectInternalContext, {
61+
advancedCreate: false,
5662
suppressActivity: true,
5763
suppressConfirmation,
58-
suppressRegistryPrompt: suppressRegistryPrompt ?? true,
5964
suppressContainerAppCreation,
6065
suppressProgress: true,
6166
suppressWizardTitle: true,

src/commands/api/getAzureContainerAppsApiProvider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import type * as api from "./vscode-azurecontainerapps.api";
1010

1111
export function getAzureContainerAppsApiProvider(): apiUtils.AzureExtensionApiProvider {
1212
return createApiProvider([<api.AzureContainerAppsExtensionApi>{
13-
// Todo: Change this to 0.0.3 later. 0.0.3 is backwards compatible anyway so this change should be fine either way.
14-
// For some reason it's causing a block on Function side, so just keep it at 0.0.1 until we figure out why
15-
apiVersion: '0.0.1',
13+
apiVersion: '1.0.0',
1614
deployImage: deployImageApi,
1715
deployWorkspaceProject: deployWorkspaceProjectApi,
1816
}]);

src/commands/api/vscode-azurecontainerapps.api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export interface DeployWorkspaceProjectOptionsContract {
2222
// Existing resources
2323
subscriptionId?: string;
2424
resourceGroupId?: string;
25+
location?: string;
2526

2627
// Workspace deployment paths (absolute fs path)
2728
rootPath?: string;
2829
srcPath?: string;
2930
dockerfilePath?: string;
3031

3132
// Options
32-
suppressRegistryPrompt?: boolean;
3333
suppressConfirmation?: boolean; // Suppress any [resource] confirmation prompts
3434
suppressContainerAppCreation?: boolean;
3535
shouldSaveDeploySettings?: boolean;

src/commands/createContainerApp/ContainerAppCreateStep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { KnownActiveRevisionsMode, type ContainerAppsAPIClient, type Ingress } f
77
import { LocationListStep } from "@microsoft/vscode-azext-azureutils";
88
import { AzureWizardExecuteStepWithActivityOutput, nonNullProp, nonNullValueAndProp, type AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils";
99
import { type Progress } from "vscode";
10-
import { containerAppsWebProvider, ImageSource } from "../../constants";
10+
import { ImageSource } from "../../constants";
1111
import { ContainerAppItem } from "../../tree/ContainerAppItem";
1212
import { createContainerAppsAPIClient } from "../../utils/azureClients";
1313
import { localize } from "../../utils/localize";
@@ -37,7 +37,7 @@ export class ContainerAppCreateStep<T extends ContainerAppCreateContext> extends
3737
} : undefined;
3838

3939
context.containerApp = ContainerAppItem.CreateContainerAppModel(await appClient.containerApps.beginCreateOrUpdateAndWait(resourceGroupName, containerAppName, {
40-
location: (await LocationListStep.getLocation(context, containerAppsWebProvider)).name,
40+
location: (await LocationListStep.getLocation(context)).name,
4141
managedEnvironmentId: context.managedEnvironment?.id,
4242
configuration: {
4343
ingress,

0 commit comments

Comments
 (0)