Setting up Apigee in VS Code

You're viewing Apigee X documentation.
View Apigee Edge documentation.

Set up Apigee in Visual Studio Code (VS Code) as described in the following sections.

Installing Apigee in VS Code

To install Apigee in VS Code:

  1. Download and install Visual Studio Code (VS Code) on your local machine.
  2. Download and install the Apigee in VS Code plug-in, as follows:
    1. Download the Apigee in VS Code plug-in (apigee-dev-1.0.0.vsix).
    2. Open VS Code.
    3. Select View > Command Palette to open the Command palette.
    4. Select Extensions: Install from VSIX.
    5. Navigate to the Apigee in VS Code plug-in, apigee-dev-1.0.0.vsix, that you downloaded in step 2 and click Install.
  3. Install the Apigee Emulator (local runtime), as follows:
    1. Pull the Apigee Emulator Docker image, as follows:
      docker pull gcr.io/apigee-release/hybrid/apigee-emulator:1.0.0-preview.1
    2. Run the Apigee Emulator container, as follows:
      docker run -e TERM=xterm-256color -d -p 8080:8080 -p 8998:8998 --dns=8.8.8.8 --privileged --name apigee-emulator -h apigee-emulator -l com.apigee.docker_planet.name=apigee-emulator gcr.io/apigee-release/hybrid/apigee-emulator:1.0.0-preview.1
        

Using version control with Apigee in VS Code

VS Code supports integration with various source control management (SCM) providers, including Git which is integrated out of the box. A rich set of source control providers is supported through the Extension Marketplace. For information about setting up SCM for VS Code, see Using version control in VS Code.

For additional guidance on setting up Apigee in VS Code, see Setting up Visual Studio Code.

Enabling archive deployment in an Apigee environment

To support local development using Apigee with VS Code, you must enable archive deployment in your Apigee environment.

Enable archive deployment as described in the following sections.

Apigee UI

To enable archive deployment in your Apigee environment, when creating an Apigee environment (outside of the provisioning wizard), select Archive under Deployment type.

Apigee API

To enable archive deployment when creating an environment using the API, set deploymentType to ARCHIVE in the request body.

For example:

curl "https://apigee.googleapis.com/v1/organizations/$ORG/environments" \
   -X POST \
   -H "Authorization: Bearer $TOKEN" \
   -H "Content-type: application/json" \
   -d \
   '{
      "name": "integration-test",
      "description": "Integration test environment",
      "displayName" : "Integration test",
      "deploymentType" : "ARCHIVE"
   }'

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtaining an OAuth 2.0 access token. For information about the curl options used in this example, see Using curl. For a description of the environment variables used, see Setting environment variables for Apigee API requests.

The following provides an example of the response:

{
  "name": "organizations/$ORG/operations/11b1ad1c-2371-473d-bcd4-f621f8d98ef7",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.apigee.v1.OperationMetadata",
    "operationType": "INSERT",
    "targetResourceName": "organizations/$ORG/environments/integration-test",
    "state": "IN_PROGRESS"
  }
}

You can check the status of the operation. For example:

curl https://apigee.googleapis.com/v1/organizations/$ORG/operations/11b1ad1c-2371-473d-bcd4-f621f8d98ef7 \
   -H "Authorization: Bearer $TOKEN"

The following provides an example of the response. Note that the state of the operation is FINISHED and the state of the environment is set to ACTIVE.

{
  "name": "organizations/$ORG/operations/11b1ad1c-2371-473d-bcd4-f621f8d98ef7",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.apigee.v1.OperationMetadata",
    "operationType": "INSERT",
    "targetResourceName": "organizations/$ORG/environments/integration-test",
    "state": "FINISHED"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.apigee.v1.Environment",
    "name": "integration-test",
    "description": "Integration test environment",
    "createdAt": "1615553880084",
    "lastModifiedAt": "1615553881911",
    "displayName": "Integration test",
    "state": "ACTIVE",
    "deploymentType": "ARCHIVE"
  }
}

For more information about the API, see Create environments API.

Next steps

After completing the installation and setup steps, get started using Apigee in VS Code: