export function getRemoteDebugLanguage()

in src/commands/remoteDebug/getRemoteDebugLanguage.ts [12:50]


export function getRemoteDebugLanguage(siteConfig: WebSiteManagementModels.SiteConfigResource, context: IActionContext): RemoteDebugLanguage {
    // We read siteConfig.linuxFxVersion to find the image version:
    //   If the app is running Windows, it will be empty
    //   If the app is running a blessed Linux image, it will contain the language and version, e.g. "NODE|8.11"
    //   If the app is running a custom Docker image, it will contain the Docker registry information, e.g. "DOCKER|repo.azurecr.io/image:tag"

    const enablePythonRemoteDebugging = getWorkspaceSetting<boolean>('enablePythonRemoteDebugging');

    if (siteConfig.linuxFxVersion) {
        let version = siteConfig.linuxFxVersion.toLowerCase();

        // Docker images will contain registry information that shouldn't be included in telemetry, so remove that information
        if (version.startsWith('docker')) {
            version = 'docker';
        }

        // Add the version to telemtry for this action
        context.telemetry.properties.linuxFxVersion = version;

        if (version.startsWith('node')) {
            const splitVersion = version.split('|');
            if (splitVersion.length > 1 && isNodeVersionSupported(splitVersion[1])) {
                return RemoteDebugLanguage.Node;
            } else {
                throw new Error(localize('nodeV811Only', 'Azure Remote Debugging is currently only supported for Node.js version >= 8.11 on Linux.'));
            }
        }

        if (enablePythonRemoteDebugging && version.startsWith('python')) {
            return RemoteDebugLanguage.Python;
        }
    }

    if (enablePythonRemoteDebugging) {
        throw new Error(localize('nodePythonOnly', 'Azure Remote Debugging is currently only supported for Node.js and Python apps on Linux.'));
    } else {
        throw new Error(localize('nodeOnly', 'Azure Remote Debugging is currently only supported for Node.js apps on Linux.'));
    }
}