Step 7: Deploy to an Apigee environment

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

After you complete local development and testing with Apigee in VS Code, you are ready to deploy your API as an archive to an Apigee environment. In this step, you'll create an Apigee environment that supports archive deployment and deploy an archive of your API proxy configuration to the Apigee environment.

  1. Create a new Apigee environment and enable archive deployment.
    1. Sign in to Apigee UI.
    2. Select Admin > Environments > Overview in the left navigation menu.
    3. Click +Environment.

      The New environment dialog displays.

    4. Enter the following information in the fields:
      Field Setting
      Display name: dev
      Environment name: dev
      Description: Developer environment
      Deployment type: Archive

      For example:

      New environment dialog showing Archive deployment type settings

    5. Click Create.
  2. Deploy an archive of your API proxy configuration to the Apigee environment.
    1. In the Terminal tab in Apigee VS Code, navigate to the myapigeeworkspace directory.
      cd myapigeeworkspace

      When you run ls the directory should contain the src folder.

    2. Run the following command:
      gcloud alpha apigee archives deploy --environment=dev --labels=release=052021.1

      The following provides an example of the response:

      Using Apigee organization dev
      Waiting for operation [b64c2665-b5ac-43cc-9e2d-232e8895c2ed] to complete...⠹
      Archive deployment with id "pzfbs8uidbdv224joz" started with operation id "b64c2665-b5ac-43cc-9e2d-232e8895c2ed"
  3. Run the following command in the Terminal tab to test your API:
    curl https://INTERNAL_LOAD_BALANCER_IP/helloworld \
      -H "Host: ENV_GROUP_HOSTNAME" \

    For more information about the variables in this example and how to set up API access, see Deploy a sample proxy.

    The following error message is displayed:

    {"fault":{"faultstring":"Failed to resolve API Key variable request.queryparam.apikey",
      "detail":{"errorcode":"steps.oauth.v2.FailedToResolveAPIKey"}}}
    

    You need to create an API product that includes the helloworld API, then create and register a developer with the API product in order to obtain an API key.

  4. Obtain an API key.
    1. Create an API product using the Apigee UI:
      1. Select Publish > API Products.
      2. Click +API Product.
      3. Enter the Product Details for your API product.
      4. Enter the following information in the fields:
        Field Setting
        Name: myproduct
        Display name: myproduct
        Environment: dev
        Access: Public
        Quota: Leave blank
        Allowed OAuth scope: Leave blank
      5. In the API resources section, click Add a proxy, select helloworld, and click Add.
      6. Click Save.
    2. Create a developer in your organization:
      1. Select Publish > Developers in the navigation menu.
      2. Click + Developer.
      3. Enter the following information in the fields:
        Field Setting
        First Name: Alex
        Last Name: Hamilton
        Username: ahamilton
        Email: ahamilton@example.com
      4. Click Create.
    3. Register an app:
      1. Select Publish > Apps.
      2. Click + App.
      3. Enter the following information in the fields:
        Field Setting
        Name: myapp
        Display name: myapp
        Developer: ahamilton@example.com
        Callback URL: Leave blank
        Notes: Leave blank
        Expiry: Never
        Product:
        1. Click Add product.
        2. Select myproduct.
        3. Click Add.
        Custom attributes: Leave blank
    4. Copy the API key.
      1. On the Apps page (Publish > Apps), click myapp.
      2. On the myapp page, click Show next to Key in the Credentials section. Notice that the API key is associated with the API product you created.
      3. Select and copy the API key.
  5. Run the curl call again passing the API key using the apikey query parameter, as follows:
    curl -v https://$PUBLIC_FACING_IP/helloworld?apikey=ZQA5euYtNeJ7ZCGCJMpvd6F2BZOmxOzY

    The following response is returned:

    {
      "root": {
        "city": "San Jose",
        "firstName": "John",
        "lastName": "Doe",
        "state": "CA"
      }
    }

Congratulations! You've successfully deployed your API archive to an Apigee environment!

In the next step, you'll promote your API archive to an Apigee production environment.

Next step

1 2 3 4 5 6 7 (NEXT) Step 8: Promote an archive to production