Examples

On This Page

To help you make the most of Nuclio, the following function examples are provided in the hack/examples Nuclio GitHub directory:

Go examples

  • Hello World (helloworld): A simple function that showcases unstructured logging and a structured response.
  • Compliance Checker (regexscan): A function that uses regular expressions to find patterns of social-security numbers (SSN), credit-card numbers, etc., using text input.
  • Image Resize and Convert (image): A function that demonstrates how to pass a binary-large object (blob) in an HTTP request body and response. The function defines an HTTP request that accepts a binary image or URL as input, converts the input to the target format and size, and returns the converted image in the HTTP response.
  • HTTP ingress (ingress): A simple function with an HTTP ingress configuration (using embedded YAML code) that routes specific URL paths to the function.
  • RabbitMQ (rabbitmq): A multi-trigger function with a configuration that connects to RabbitMQ to read messages and write them to local ephemeral storage. If triggered with an HTTP GET request, the function returns the messages that it read from RabbitMQ.
  • [Azure Event Hub]((https://github.com/nuclio/nuclio/tree/master/hack/examples/golang/eventhub) (eventhub): An Azure Event Hub triggered function with a configuration that connects to an Azure Event Hub. The funciton reads messages from two partitions, process the messages, invokes another function, and sends the processed payload to another Azure Event Hub. You can find a full demo scenario here.

Python examples

  • Hello World (helloworld): A simple function that showcases unstructured logging and a structured response.
  • Encrypt (encrypt): A function that uses a third-party Python package to encrypt the event body, and showcases build commands for installing both OS-level and Python packages.
  • Face Recognizer (face): A function that uses Microsoft’s face API, configured with function environment variables. The function uses third-party Python packages, which are installed by using an inline configuration.
  • Sentiment Analysis (sentiments): A function that uses the vaderSentiment library to classify text strings into a negative or positive sentiment score.
  • TensorFlow (tensorflow): A function that uses the inception model of the TensorFlow open-source machine-learning library to classify images. The function demonstrates advanced uses of Nuclio with a custom base image, third-party Python packages, pre-loading data into function memory (the AI Model), structured logging, and exception handling.

Shell examples

  • Image convert (img-convert): A wrapper script around ImageMagick’s convert executable, which is capable of generating thumbnails from received images (among other things).

NodeJS examples

  • Reverser (reverser): Returns the reverse of the body received in the event.
  • Dates (dates): Uses moment.js (which is installed as part of the build) to add a specified amount of time to "now", and returns this amount as a string.

.NET Core 2.0 examples

  • Reverser: Returns the reverse of the body received in the event.
  • Hello World: (helloworld): A simple function that showcases structured logging, unstructured logging and a structured response.

Java Examples

  • Empty (empty): A simple function that returns an empty string.
  • Reverser (reverser): Returns the reverse of the body received in the event, also shows how to log.