private static async getOrCreateContainerAppEnvironment()

in azurecontainerapps.ts [334:363]


    private static async getOrCreateContainerAppEnvironment(
        containerAppName: string,
        resourceGroup: string,
        location: string): Promise<string> {
        // Get the Container App environment if it was provided
        let containerAppEnvironment: string = this.toolHelper.getInput('containerAppEnvironment', false);

        // See if we can reuse an existing Container App environment found in the resource group
        if (this.util.isNullOrEmpty(containerAppEnvironment)) {
            const existingContainerAppEnvironment: string = await this.appHelper.getExistingContainerAppEnvironment(resourceGroup);
            if (!this.util.isNullOrEmpty(existingContainerAppEnvironment)) {
                this.toolHelper.writeInfo(`Existing Container App environment found in resource group: ${existingContainerAppEnvironment}`);
                return existingContainerAppEnvironment
            }
        }

        // Generate the Container App environment name if it was not provided
        if (this.util.isNullOrEmpty(containerAppEnvironment)) {
            containerAppEnvironment = `${containerAppName}-env`;
            this.toolHelper.writeInfo(`Default Container App environment name: ${containerAppEnvironment}`);
        }

        // Determine if the Container App environment currently exists and create one if it doesn't
        const containerAppEnvironmentExists: boolean = await this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup);
        if (!containerAppEnvironmentExists) {
            await this.appHelper.createContainerAppEnvironment(containerAppEnvironment, resourceGroup, location);
        }

        return containerAppEnvironment;
    }