33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { LocationListStep , VerifyProvidersStep } from "@microsoft/vscode-azext-azureutils" ;
7- import { AzureWizard , AzureWizardExecuteStep , AzureWizardPromptStep , IActionContext , ICreateChildImplContext , createSubscriptionContext , nonNullProp } from "@microsoft/vscode-azext-utils" ;
6+ import type { ResourceGroup } from "@azure/arm-resources" ;
7+ import { LocationListStep , ResourceGroupListStep , VerifyProvidersStep } from "@microsoft/vscode-azext-azureutils" ;
8+ import { AzureWizard , AzureWizardExecuteStep , AzureWizardPromptStep , IActionContext , createSubscriptionContext , nonNullProp , nonNullValue , nonNullValueAndProp } from "@microsoft/vscode-azext-utils" ;
89import { webProvider } from "../../constants" ;
910import { ext } from "../../extensionVariables" ;
1011import { ContainerAppItem } from "../../tree/ContainerAppItem" ;
@@ -19,21 +20,19 @@ import { ContainerAppNameStep } from "./ContainerAppNameStep";
1920import type { ICreateContainerAppContext } from "./ICreateContainerAppContext" ;
2021import { showContainerAppCreated } from "./showContainerAppCreated" ;
2122
22- export async function createContainerApp ( context : IActionContext & Partial < ICreateChildImplContext > & Partial < ICreateContainerAppContext > , node ?: ManagedEnvironmentItem ) : Promise < ContainerAppItem > {
23- node ??= await pickEnvironment ( context , {
24- title : localize ( 'createContainerApp' , 'Create Container App' ) ,
25- } ) ;
23+ export async function createContainerApp ( context : IActionContext , node ?: ManagedEnvironmentItem ) : Promise < ContainerAppItem > {
24+ node ??= await pickEnvironment ( context ) ;
2625
2726 const wizardContext : ICreateContainerAppContext = {
2827 ...context ,
2928 ...createSubscriptionContext ( node . subscription ) ,
30- ...( await createActivityContext ( ) ) ,
29+ ...await createActivityContext ( ) ,
3130 subscription : node . subscription ,
3231 managedEnvironmentId : node . managedEnvironment . id ,
3332 alwaysPromptIngress : true
3433 } ;
3534
36- const title : string = localize ( 'createContainerApp' , 'Create Container App ' ) ;
35+ const title : string = localize ( 'createContainerApp' , 'Create container app ' ) ;
3736
3837 const promptSteps : AzureWizardPromptStep < ICreateContainerAppContext > [ ] = [
3938 new ContainerAppNameStep ( ) ,
@@ -46,7 +45,11 @@ export async function createContainerApp(context: IActionContext & Partial<ICrea
4645 new ContainerAppCreateStep ( ) ,
4746 ] ;
4847
49- wizardContext . newResourceGroupName = node . resource . resourceGroup ;
48+ // Use the same resource group and location as the parent resource (managed environment)
49+ const resourceGroupName : string = nonNullValueAndProp ( node . resource , 'resourceGroup' ) ;
50+ const resourceGroups : ResourceGroup [ ] = await ResourceGroupListStep . getResourceGroups ( wizardContext ) ;
51+ wizardContext . resourceGroup = nonNullValue ( resourceGroups . find ( rg => rg . name === resourceGroupName ) ) ;
52+
5053 await LocationListStep . setLocation ( wizardContext , nonNullProp ( node . resource , 'location' ) ) ;
5154
5255 const wizard : AzureWizard < ICreateContainerAppContext > = new AzureWizard ( wizardContext , {
@@ -64,9 +67,9 @@ export async function createContainerApp(context: IActionContext & Partial<ICrea
6467
6568 await ext . state . showCreatingChild (
6669 node . managedEnvironment . id ,
67- localize ( 'creatingContainerApp' , 'Creating Container App "{0}"...' , newContainerAppName ) ,
70+ localize ( 'creatingContainerApp' , 'Creating container app "{0}"...' , newContainerAppName ) ,
6871 async ( ) => {
69- wizardContext . activityTitle = localize ( 'createNamedContainerApp' , 'Create Container App "{0}"' , newContainerAppName ) ;
72+ wizardContext . activityTitle = localize ( 'createNamedContainerApp' , 'Create container app "{0}"' , newContainerAppName ) ;
7073 await wizard . execute ( ) ;
7174 } ) ;
7275
0 commit comments