Skip to content

Latest commit

 

History

History
45 lines (30 loc) · 4.52 KB

README.md

File metadata and controls

45 lines (30 loc) · 4.52 KB

Examples

To help you make the most of Nuclio, the following function examples are provided:

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 (eventhub): An Azure Event Hub triggered function with a configuration that connects to an Azure Event Hub. The function 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.

  • Call Function (callfunction): A set of two functions that demonstrates the CallFunction feature:

    • fibonacci - For input parameter n, returns the n-th number in the Fibonacci series (fib(n)).
    • fibonaccisum - Uses CallFunction to call the fibonacci function for input numbers 2, 10, and 17, and returns the sum of the three returned Fibonacci numbers (fib(2)+fib(10)+fib(17)).

    To try the example, deploy the fibonacci function and name it fibonacci; then, deploy the fibonaccisum function to the same namespace, using your preferred function name, and call it.

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 3.1 examples

  • Reverser (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.