private static async getLocation()

in azurecontainerapps.ts [254:297]


    private static async getLocation(): Promise<string> {
        // Set deployment location, if provided
        let location: string = this.toolHelper.getInput('location', false);
        if (!this.util.isNullOrEmpty(location)) {
            return location;
        }

        // If no location was provided, attempt to discover the location of the existing Container App Environment linked to the Container App
        // or Container App Environment provided in the resource group or use the default location.
        // Get the resource group if it was provided
        let resourceGroup: string = this.toolHelper.getInput('resourceGroup', false);

        if (!this.util.isNullOrEmpty(resourceGroup)) {
            // Check if Container App exists in the resource group provided and get the location from the Container App Environment linked to it
            let containerAppExists = await this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup);
            if (containerAppExists) {
                // Get the name of the Container App Environment linked to the Container App
                var environmentName = await this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup);

                // Check if environment exists in the resource group provided and get the location
                var containerAppEnvironmentExistsInResourceGroup = !this.util.isNullOrEmpty(environmentName) ? await this.appHelper.doesContainerAppEnvironmentExist(environmentName, resourceGroup) : false;
                if (containerAppEnvironmentExistsInResourceGroup) {
                    // Get the location of the Container App Environment linked to the Container App
                    location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup);
                    return location;
                }
            }

            // Get the Container App Environment name if it was provided
            let containerAppEnvironment: string = this.toolHelper.getInput('containerAppEnvironment', false);

            // Check if Container App Environment is provided and exits in the resource group provided and get the location
            let containerAppEnvironmentExists = !this.util.isNullOrEmpty(containerAppEnvironment) ? await this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup) : false;
            if (containerAppEnvironmentExists) {
                location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, resourceGroup);
                return location;
            }
        }

        // Get the default location if the Container App or Container App Environment was not found in the resource group provided.
        location = await this.appHelper.getDefaultContainerAppLocation();
        return location;

    }