This sample app adds custom java plugin code, system and staging tests, and is an introduction into integrating with a CI/CD pipeline. It extends the Quick Start with:

This sample application is great to deploy to both the Dev and Prod Environments in the Free Trial - experience how easy it is to develop and application using Vespa Cloud, and deploy for production serving.

Prerequisites: git, Java 11, mvn 3.6.1 and openssl. See Getting Started for troubleshooting. Security notes:

  • To deploy, a user API key is required, see step 4.
  • To read and write to the instance's endpoint, a certificate and a private key is required, see step 2. Find more details in Data Plane, see "Client certificate".

Dev Environment

  1. Download sample apps:

    $ git clone && \
      cd sample-apps/vespa-cloud/album-recommendation-searcher

  2. Get a X.509 certificate and private key. Create a self-signed certificate / private key:

    $ openssl req -x509 -nodes -days 14 -newkey rsa:4096 \
      -subj "/CN=cloud.vespa.example" \
      -keyout data-plane-private-key.pem -out data-plane-public-cert.pem

  3. Add certificate to application package (it must be copied as clients.pem):

    $ mkdir -p src/main/application/security && \
      cp data-plane-public-cert.pem src/main/application/security/clients.pem

  4. At, choose tenant and click Keys to generate and save the user API key. The key is saved to $HOME/Downloads/USER.TENANTNAME.pem. Then click "Create application" - use any name for the application.

  5. Update tenant and application in pom.xml — use the values entered in the console in 4.

  6. Build the app, deploy your own instance (my-instance here) to the dev environment and wait for it to start — update apiKeyFile to be the file downloaded above:

    $ mvn clean package vespa:deploy -DapiKeyFile=$HOME/Downloads/USER.TENANTNAME.pem -Dinstance=my-instance

  7. Alternatively, put the key in an environment variable:

    $ API_KEY=`echo $VESPA_TEAM_API_KEY | openssl base64 -A -a -d`
    $ mvn clean package vespa:deploy -DapiKey="$API_KEY" -Dinstance=my-instance

  8. Now is a good time to read automated-deployments, as first time deployments takes a few minutes. The endpoint URL is printed in the Install application section when the deployment is successful - store this (change root to actual name) for later steps and test it (the massive JSON output is expected). Also see using a browser:

    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem $ENDPOINT

  9. Feed documents:

    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem \
      -H "Content-Type:application/json" --data-binary @src/test/resources/A-Head-Full-of-Dreams.json \
    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem \
      -H "Content-Type:application/json" --data-binary @src/test/resources/Love-Is-Here-To-Stay.json \
    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem \
      -H "Content-Type:application/json" --data-binary @src/test/resources/Hardwired...To-Self-Destruct.json \

  10. Dump all document using visit:

    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem \

  11. Recommend albums, send user profile in query:

    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem \
    Limit to albums with the term "to" in title:
    $ curl --cert ./data-plane-public-cert.pem --key ./data-plane-private-key.pem \

Prod Environment

  1. Vespa Cloud has support for running system and staging tests, used in automated-deployments. These tests are run as JUnit tests. To develop such tests, deploy the application to dev (like above) and run tests like FeedAndSearchSystemTest:

    $ mvn test \
      -Dtest.categories=system \
      -DdataPlaneKeyFile=data-plane-private-key.pem -DdataPlaneCertificateFile=data-plane-public-cert.pem \
    The apiKey is used to fetch the dev instance's endpoints. The data plane key and certificate pair is used by to access the application endpoint. Find more details in testing and Vespa Cloud API.

  2. To run tests against a deployment running in Docker on localhost (instead of using dev), configure endpoint location:

        "localEndpoints": {
            "container": "http://localhost:8080/"
    See system tests for details. Refer to album-recommendation-selfhosted for how to create the application package.

  3. When system and staging tests are ready, deploy to production:

    $ mvn vespa:compileVersion -DapiKey="$API_KEY"
    $ mvn -Dvespa.compile.version="$(cat target/vespa.compile.version)" \
      -DapiKey="$API_KEY" \
      -DsourceUrl="$(git rev-parse HEAD)/vespa-cloud/album-recommendation-searcher" \
      package vespa:submit