Hosted Targets tasks

Undeploying a Hosted Targets proxy

When you undeploy an Edge proxy that includes a Hosted Targets application, the associated Hosted Targets app is undeployed, but the underlying application image is not deleted. If you redeploy the proxy, the Hosted Targets app is redeployed.

Deleting a Hosted Targets proxy

After you delete a Hosted Targets proxy, the underlying runtime instances will stop running within some amount of time. The application code will persist, however.

Accessing log files

Log files are useful for debugging and troubleshooting. You can view two types of log files for a Hosted Targets deployment:

  • Build log - Shows you output related to deploying and building a Hosted Targets app.
  • Runtime log - Shows you output related to the running Hosted Targets app. Runtime logs are scoped to the environment and show log information for the currently deployed proxy revision.

Accessing logs from the Edge UI

  1. Go to: apigee.com/edge
  2. Enter your login credentials and click Sign In.
  3. Ensure that you are in the New Edge UI. If not, click Try New Edge in the Classic Edge navigation bar.
  4. Select Develop > API Proxies in the side navigation menu.
  5. Select the proxy for which you want to view logs.
  6. Click the Develop tab.
  7. To see the build log, click Build Logs.
  8. To see the runtime log, click Runtime Logs.

Accessing logs with the API

You can also use an Edge Management API to retrieve Hosted Targets logs. For details, see Get Cached Node.js Logs.

Using a private npm repository

This section explains how to deploy a Node.js proxy to Hosted Targets in cases where you use a private NPM repository in your development environment.

What you need to know about using a private repository

When you deploy a Node.js app to Edge, all of your project's dependencies are imported automatically as part of the deployment process. Essentially, Hosted Targets runs npm install on your code when it is deployed. However, if you use a private NPM repository in your development environment, the private dependencies cannot be resolved in the Cloud. In this case, the solution is to use the --bundled-dependencies option when you use the deployment utility apigeetool. See also Deploy Node.js from your system to Edge.

When you use the --bundled-dependencies flag on apigeetool, your Node.js app will be uploaded to Hosted Targets and any local/private files that are listed in the bundledDependencies array in package.json are zipped and uploaded with the bundle.

Although not a common situation, be aware that if you mirror a public NPM repository internally, your deployment will fail if your deployment bundle includes a .npmrc or package-lock.json file that points to your private mirror. In this case, be sure to omit .npmrc or package-lock.json from your proxy bundle that you intend to deploy.

Deploying with a private NPM repository

To use modules provided from a private NPM repository, follow these steps:

  1. Log into npm:
    npm login
  2. Get an npm auth token:
    1. Locate your .npmrc (should be in ~/.npmrc).
    2. In your .npmrc, note the token at the end of the line that looks like this:

      //registry.npmjs.org/:_authToken=****
    3. Or use the npm token <list | create | revoke> commands to list, create, or revoke an auth token. See the npm-token documentation for more details.
  3. In a browser, log into your Apigee account: login.apigee.com.
  4. Go to the Key Value Maps configuration page:
    1. In the New Edge UI: Admin > Environments > Key Value Maps.
    2. In the Classic UI: APIs > Environment Configuration > Key Value Maps.
  5. Click + Key Value Map.
  6. In the New Key Value Map dialog, enter a name and select Encrypted.
  7. Click Add.
  8. Add the auth token you previously located or created as a new entry in each of the KVMs that you just created.
  9. In your app.yaml file add an entry that references the KVM and key associated with the npm auth token. It should look something like this:
  10. env:
    - name: NPM_TOKEN
     valueRef:
       name: npm_store
       key: private_token

    Where:

    • The top level name attribute corresponds to the name of the environment variable that will be created.
    • The name under valueRef corresponds to the KVM you created previously.
    • The key attribute corresponds to the key that maps to the npm token you added to the KVM.
  11. Create a .npmrc file in the same directory as your package.json. This file should look similar to this:
    //registry.npmjs.org/:_authToken=${NPM_TOKEN}
    or if you’re not using registry.npmjs.org you can set the scope in the .npmrc file by adding a line like this @myscope:registry=https://mycustomregistry.example.org See also the npmrc documentation.
  12. Upload or update your Node.js proxy with the .npmrc file and app.yaml files included.
  13. Make sure your new or updated proxy deploys and works with the desired private repository module.
  14. If the proxy does not deploy, check the build logs to see if it failed on installing the private npm module. If so:
    1. Under the develop tab, make sure the .npmrc is present.
    2. Make sure your token is valid (try installing the module locally with the token present in the kvm).
    3. If you are using a custom scope, make sure that is set.