unable to deploy a node app proxy via management api

usergrid-module-2.ziphi Team,

Good day.

am unable to upload my node app into the a proxy on apigee.

could you please help me ?

com.apigee.kernel.exceptions.spi.UncheckedException{ code = application.bootstrap.FailedToConfigure, message = Configuration failed, associated contexts = []}

is the error am getting , while trying to deploy.

please find the node app attached herewith.

Thank you,

Regards,

Sreenivas S P

Solved Solved
1 6 490
1 ACCEPTED SOLUTION

Hi Sreenivas

I see your ZIP file. A couple things.

  • You've included the config.js file which itself includes credentials to connect to your BaaS. That's not secure. For that reason, I've removed the zip from your post.
  • The zip contains a nodejs app. You didn't describe exactly how you are importing the zip and deploying. But if you try to just import that zip, it's not the right form for Apigee Edge. When you want to deploy an API Proxy to Apigee Edge, you need to package it in a different form. I'm looking in the Apigee documentation, and frustratingly, I have not been able to find a page that clearly defines the format of the "zip bundle" that you must use to import a proxy to Apigee Edge. ( @Floyd Jones - maybe you can help me find what I'm looking for in the docs? If it does not exist, then it seems like we should add something that defines the format.)

This illustrates the format for a ZIP that you can import using the Management API:

Archive:  apiproxy.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  05-16-2017 10:24   apiproxy/
      384  05-16-2017 10:24   apiproxy/dynamite-jira-bot.xml
        0  05-09-2017 18:39   apiproxy/policies/
     1098  05-09-2017 17:36   apiproxy/policies/AM-BadResponseMsg.xml
      619  03-07-2017 15:45   apiproxy/policies/AM-CleanResponseHeaders.xml
     2035  05-09-2017 18:30   apiproxy/policies/AM-GoodResponseMsg-1.xml
     1997  05-09-2017 18:30   apiproxy/policies/AM-GoodResponseMsg-2.xml
     1954  05-09-2017 18:33   apiproxy/policies/AM-GoodResponseMsg-3.xml
     1756  05-09-2017 18:39   apiproxy/policies/AM-GoodResponseMsg-4.xml
     1607  05-09-2017 18:39   apiproxy/policies/AM-GoodResponseMsg.xml
      588  05-04-2017 17:47   apiproxy/policies/AM-TraceAuthn.xml
      272  05-04-2017 17:47   apiproxy/policies/AM-TraceResponse.xml
      383  03-07-2017 16:57   apiproxy/policies/BasicAuth-Encode.xml
      203  03-07-2017 17:05   apiproxy/policies/JS-ExtractJiraTicket.xml
      254  05-04-2017 17:31   apiproxy/policies/JS-RipInboundJson.xml
      260  05-04-2017 17:31   apiproxy/policies/JS-RipJiraResponse.xml
      345  03-07-2017 16:59   apiproxy/policies/KVM-Get-JiraCreds.xml
      440  03-08-2017 10:31   apiproxy/policies/RF-InvalidRequest.xml
      421  03-07-2017 15:45   apiproxy/policies/RF-UnknownRequest.xml
      670  05-09-2017 13:27   apiproxy/policies/SC-GetJiraTicket.xml
        0  05-11-2017 11:54   apiproxy/proxies/
     2975  05-11-2017 11:54   apiproxy/proxies/default.xml
        0  03-08-2017 10:43   apiproxy/resources/
        0  08-09-2017 12:07   apiproxy/resources/jsc/
      652  08-09-2017 12:07   apiproxy/resources/jsc/extractJiraTicket.js
     3192  05-16-2017 10:18   apiproxy/resources/jsc/extractJsonToContextVars.js
        0  08-09-2017 13:27   apiproxy/resources/node/
     2230  05-16-2017 10:24   apiproxy/resources/node/index.js
  1054012  08-09-2017 13:25   apiproxy/resources/node/node_modules.zip
      363  08-09-2017 13:10   apiproxy/resources/node/package.json
        0  03-08-2017 12:04   apiproxy/targets/
      364  03-08-2017 11:09   apiproxy/targets/momentify.xml
---------                     -------
  1079074                     32 files

Notice the root directory in the zip is "apiproxy". Then there is a set of subdirectories - policies, proxies, resources, targets. If you have a nodejs app that you want to deploy with your API Proxy, then it goes into the resources/node directory.

What I have done is packaged the node_modules into a node_modules.zip, but that is not necessary. As an alternative, omit node_modules.zip, specify the dependencies in package.json, import the zip, and then use the Management API to run "npm install" on the imported proxy.

Does this help?

View solution in original post

6 REPLIES 6

Hi Sreenivas

I see your ZIP file. A couple things.

  • You've included the config.js file which itself includes credentials to connect to your BaaS. That's not secure. For that reason, I've removed the zip from your post.
  • The zip contains a nodejs app. You didn't describe exactly how you are importing the zip and deploying. But if you try to just import that zip, it's not the right form for Apigee Edge. When you want to deploy an API Proxy to Apigee Edge, you need to package it in a different form. I'm looking in the Apigee documentation, and frustratingly, I have not been able to find a page that clearly defines the format of the "zip bundle" that you must use to import a proxy to Apigee Edge. ( @Floyd Jones - maybe you can help me find what I'm looking for in the docs? If it does not exist, then it seems like we should add something that defines the format.)

This illustrates the format for a ZIP that you can import using the Management API:

Archive:  apiproxy.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  05-16-2017 10:24   apiproxy/
      384  05-16-2017 10:24   apiproxy/dynamite-jira-bot.xml
        0  05-09-2017 18:39   apiproxy/policies/
     1098  05-09-2017 17:36   apiproxy/policies/AM-BadResponseMsg.xml
      619  03-07-2017 15:45   apiproxy/policies/AM-CleanResponseHeaders.xml
     2035  05-09-2017 18:30   apiproxy/policies/AM-GoodResponseMsg-1.xml
     1997  05-09-2017 18:30   apiproxy/policies/AM-GoodResponseMsg-2.xml
     1954  05-09-2017 18:33   apiproxy/policies/AM-GoodResponseMsg-3.xml
     1756  05-09-2017 18:39   apiproxy/policies/AM-GoodResponseMsg-4.xml
     1607  05-09-2017 18:39   apiproxy/policies/AM-GoodResponseMsg.xml
      588  05-04-2017 17:47   apiproxy/policies/AM-TraceAuthn.xml
      272  05-04-2017 17:47   apiproxy/policies/AM-TraceResponse.xml
      383  03-07-2017 16:57   apiproxy/policies/BasicAuth-Encode.xml
      203  03-07-2017 17:05   apiproxy/policies/JS-ExtractJiraTicket.xml
      254  05-04-2017 17:31   apiproxy/policies/JS-RipInboundJson.xml
      260  05-04-2017 17:31   apiproxy/policies/JS-RipJiraResponse.xml
      345  03-07-2017 16:59   apiproxy/policies/KVM-Get-JiraCreds.xml
      440  03-08-2017 10:31   apiproxy/policies/RF-InvalidRequest.xml
      421  03-07-2017 15:45   apiproxy/policies/RF-UnknownRequest.xml
      670  05-09-2017 13:27   apiproxy/policies/SC-GetJiraTicket.xml
        0  05-11-2017 11:54   apiproxy/proxies/
     2975  05-11-2017 11:54   apiproxy/proxies/default.xml
        0  03-08-2017 10:43   apiproxy/resources/
        0  08-09-2017 12:07   apiproxy/resources/jsc/
      652  08-09-2017 12:07   apiproxy/resources/jsc/extractJiraTicket.js
     3192  05-16-2017 10:18   apiproxy/resources/jsc/extractJsonToContextVars.js
        0  08-09-2017 13:27   apiproxy/resources/node/
     2230  05-16-2017 10:24   apiproxy/resources/node/index.js
  1054012  08-09-2017 13:25   apiproxy/resources/node/node_modules.zip
      363  08-09-2017 13:10   apiproxy/resources/node/package.json
        0  03-08-2017 12:04   apiproxy/targets/
      364  03-08-2017 11:09   apiproxy/targets/momentify.xml
---------                     -------
  1079074                     32 files

Notice the root directory in the zip is "apiproxy". Then there is a set of subdirectories - policies, proxies, resources, targets. If you have a nodejs app that you want to deploy with your API Proxy, then it goes into the resources/node directory.

What I have done is packaged the node_modules into a node_modules.zip, but that is not necessary. As an alternative, omit node_modules.zip, specify the dependencies in package.json, import the zip, and then use the Management API to run "npm install" on the imported proxy.

Does this help?

hi Dino,

Good day.

Thank you for the response, will try to implement and suggest .

Regards,

Sreenivas S P

hi Dino,

Good day.

Thank you, I was able to upload this proxy and deploy now.

would it be possible to have a document as you already mentioned for this.

also, it might help if the dev boot camp videos have a bit more detail on the deploy process itself.

I understand that we already have a python based tool for doing this activity, however , it helps if we could understand the way it is implemented ( for folks like me who dont know python).

Thank you so much again!

Regards,

Sreenivas S P

Hi Sreenivas, I'm glad to hear you were able to make progress.

Yes, I agree that it would be good to deliver more information on importing and deploying API Proxies.

There are two distinct steps: import, and deploy.

IMPORT just sends a ZIP bundle into Edge, and tells Edge "this is the definition of an API Proxy bundle, which includes a set of one or more proxy endpoints, a set of zero or more target endpoints, a set of zero or more policies, and a set of zero or more resources of various types. Please store it under the name X (provided during import). "

DEPLOY tells Edge - "make that API Proxy _active_. Start forwarding requests that match the basepath, into the proxy endpoints for that proxy."

Both Import and Deploy are performed via Administrative APIs. The Admin APIs can be wrapped by any sort of programming language or scripting tool, like Java, Python, Powershell, or nodejs.

There are also complementary actions for API proxies like:

EXPORT - get the proxy bundle in a zip file format. It contains all of the assets I described above - policies, resources, and the definitions of proxy endpoints and target endpoints.

UNDEPLOY - the opposite of DEPLOY. Edge will stop forwarding requests to the API Proxy endpoints.

DELETE - erase all record of the API proxy from the Edge data store.

These too, can all be performed via Administrative APIs.

There is a python tool, for importing and deploying proxies. But there are also other tools that do similar things, like apigeetool (relies on nodejs), pushapi (if you like Bash), importAndDeploy.js (another nodejs option), and a powershell module.

@Dino and @Sreenivas Sadhu Prabhakara - We do have a small and well-hidden 😕 section in the docs on directory structure:

https://docs.apigee.com/api-services/reference/api-proxy-configuration-reference#apiproxystructure

But it's not good enough by a mile, so I've filed a doc bug to create a new, more visible section about proxy structure. (68816339) Apologies for the confusion.

Sreenivas, if it helps, here's a topic that describes different deployment options.

https://docs.apigee.com/api-services/content/understanding-deployment

From that section we'll link to the new topic, so that when users want to understand or troubleshoot deployment, the deployment docs will highlight the need for a proper file structure.

Floyd, thank you! Maybe that doc is just fine, if we

- add some mention of node, xsd, wsdl and java resources (and there will be the "hosted" resource type in the near future)

- hyperlink to that page from the other pages that refer to "zip bundles".

- add some information about how to create such a zip bundle on various platforms - like OSX or Windows.

- made it so that reasonable search efforts would pop it to the top somehow.

But that page starts to get pretty long, if you do all of that.