Skip to content

Upgrading Extensions for V2 Compatibility

Alex Weininger edited this page Oct 13, 2022 · 20 revisions

Context

Client extensions will undergo two updates related to the V2 API.

  1. Updates needed to make client extension compatible with V2 API, without actually consuming the V2 API.
  2. Full upgrade and migration to the V2 API. Lots of code changes will be required for this step.

This is a guide for part 1 of the upgrade.

Migrating

Make these changes and raise a PR against the api-v2 branch (create the api-v2 branch if it doesn't exist).

Prerequisites

  • Update utils package

Currently, the latest utils package is https://github.com/microsoft/vscode-azuretools/pull/1229

Code changes

  • Replace registerCommand uses with registerCommandWithTreeNodeUnwrapping
  • Resolvers must be registered with an AzExtResourceType ID
    • The id argument when calling registerApplicationResourceResolver must be an AzExtResourceType.

Extension manifest updates

  • Add V2 contributions to package.json
    "contributes": {
        "x-azResourcesV2": {
            "application": {
                "branches": [
                    {
                        "type": "FunctionApp" // must match ID used to register the resolver
                    }
                ]
            },
            // needed if extension contributes workspace views
            "workspace": {
                "branches": [
                    {
                        "type": "func" // must match ID used to register the workspace resource provider
                    }
                ],
                "resources": [
                    {
                        "type": "func" // must match ID used to register the workspace resource provider
                    }
                ]
            }
        },
  • Commands should show on azureResourceGroupsV2 view instead of azureResourceGroups view
  • Change commands attached to azureResourceTypeGroup tree items to use AzExtResourceType contexts Example

Use Azure Functions as an example

Testing

Run the extension alongside Resource Groups, specifically the changes in this PR https://github.com/microsoft/vscode-azureresourcegroups/pull/358.

In Resource Groups repo:

  1. Checkout the bmw/philliphoff-resource-api-compatshim branch.
  2. Install the local utils build from https://github.com/microsoft/vscode-azuretools/pull/1229
  3. Run npm run compile

In client extension:

  1. Run and Debug the "Launch Extension + Host" configuration. You can create it if it doesn't exist. Example
Clone this wiki locally