Skip to content

Azure Functions extension API

Eric Jizba edited this page Mar 23, 2021 · 1 revision

We provide an API for our extension that can be retrieved like this:

import { extensions } from "vscode";
import { AzureExtensionApiProvider } from "vscode-azureextensionui/api";
import { AzureFunctionsExtensionApi } from "./vscode-azurefunctions.api";

export async function getExtensionApi(): Promise<AzureFunctionsExtensionApi | undefined> {
    const extensionId = 'ms-azuretools.vscode-azurefunctions';
    const extension = extensions.getExtension<AzureExtensionApiProvider>(extensionId);
    return extension?.exports?.getApi<AzureFunctionsExtensionApi>('^1.0.0');
}

It is recommended that you either list our extension as a dependency in your package.json and/or add more logic to make sure our extension is both installed and activated before you use the API. We also recommend copying the following "types" files to your repo, which has more information about the API:

NOTE: Using commands directly through executeCommand has been deprecated.