private derivePublishMethod()

in src/handlers/contentPreparer.ts [171:217]


    private derivePublishMethod(
        state: StateConstant,
        packageType: PackageType,
        osType: RuntimeStackConstant,
        sku: FunctionSkuConstant,
        authenticationType: AuthenticationType,
        params: IActionParameters
    ): PublishMethodConstant {
        // Package Type Check early
        if (packageType !== PackageType.zip && packageType !== PackageType.folder) {
            throw new ValidationError(
                state, "Derive Publish Method",
                "only accepts zip or folder. Any other deployment sources such as URL or .jar file currently are " +
                "not supported in GitHub Action."
            );
        }

        if (authenticationType == AuthenticationType.Scm) {
            // Flex Consumption plan uses api/publish endpoint
            if (!!params.sku && FunctionSkuUtil.FromString(params.sku) === FunctionSkuConstant.FlexConsumption) {
                Logger.Info('Will use Kudu https://<scmsite>/api/publish to deploy since Flex consumption plan is detected.');
                return PublishMethodConstant.OneDeployFlex;
            }
            // Uses api/zipdeploy endpoint if scm credential is provided
            else{
                Logger.Info('Will use Kudu https://<scmsite>/api/zipdeploy to deploy since publish-profile is detected.');
                return PublishMethodConstant.ZipDeploy;
            }
        }

        // Flex Consumption plan uses api/publish endpoint
        if (osType === RuntimeStackConstant.Linux && sku === FunctionSkuConstant.FlexConsumption) {
            Logger.Info('Will use Kudu https://<scmsite>/api/publish to deploy since Flex consumption plan is detected.');
            return PublishMethodConstant.OneDeployFlex;
        }
        
        // Linux Consumption sets WEBSITE_RUN_FROM_PACKAGE app settings when scm credential is not available
        if (osType === RuntimeStackConstant.Linux && sku === FunctionSkuConstant.Consumption) {
            Logger.Info('Will use WEBSITE_RUN_FROM_PACKAGE to deploy since RBAC is detected and your function app is ' +
                        'on Linux Consumption.');
            return PublishMethodConstant.WebsiteRunFromPackageDeploy;
        }

        // Rest Skus which support api/zipdeploy endpoint
        Logger.Info('Will use https://<scmsite>/api/zipdeploy to deploy since RBAC Azure credential is detected.');
        return PublishMethodConstant.ZipDeploy;
    }