snctl pulsar admin functions create \
--tenant public \
--namespace default \
--name function1 \
--inputs persistent://public/default/test-node-input \
--output persistent://public/default/test-node-output \
--classname exclamation \
--py function://public/default/node-exclamation@v0.1 \
--custom-runtime-options '{"genericKind": "nodejs"}' \
--sn-service-account $SERVICE_ACCOUNT
Only Pulsar 4.0.x clusters running version 4.0.10.6 or later, or Pulsar 4.2.x clusters running version 4.2.1.4 or later, support the --sn-service-account flag.You can use --as-service-account instead of --sn-service-account if you are using other versions of Pulsar clusters.
Since Pulsar doesn’t support NodeJs runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "nodejs"}' to make it work.
You should see something like this:Created function1 successfully
pulsarctl functions create \
--tenant public \
--namespace default \
--name function1 \
--inputs persistent://public/default/test-node-input \
--output persistent://public/default/test-node-output \
--classname exclamation \
--py function://public/default/node-exclamation@v0.1 \
--custom-runtime-options '{"genericKind": "nodejs"}'
Since Pulsar doesn’t support NodeJs runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "nodejs"}' to make it work.
You should see something like this:Created function1 successfully
./bin/pulsar-admin \
--admin-url "${WEB_SERVICE_URL}" \
--auth-plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \
--auth-params '{"privateKey":"file:///YOUR-KEY-FILE-PATH","issuerUrl":"https://auth.streamnative.cloud/","audience":"urn:sn:pulsar:${orgName}:${instanceName}}' \
functions create \
--tenant public \
--namespace default \
--name function1 \
--inputs persistent://public/default/test-node-input \
--output persistent://public/default/test-node-output \
--classname exclamation \
--py function://public/default/node-exclamation@v0.1 \
--custom-runtime-options '{"genericKind": "nodejs"}'
Since Pulsar doesn’t support NodeJs runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "nodejs"}' to make it work.
You should see something like this:If you would like to create a function configuration using the REST API you can
do so using CURL.curl -X POST ${WEB_SERVICE_URL}/admin/v3/functions/public/default/${FUNCTION_NAME} \
-H 'Authorization: Bearer ${TOKEN}' \
-H "Content-Type: multipart/form-data" \
-F 'functionConfig={"name": "${FUNCTION_NAME}", "tenant": "public", "namespace": "default", "runtime": "PYTHON", "py": "function://public/default/${PACKAGE_NAME}@${PACKAGE_VERSION}", "output": "public/default/output-test", "inputs": ["public/default/input"], "className": "exclamation", "customRuntimeOptions": "{\"genericKind\": \"nodejs\"}"};type=application/json' \
-F 'url=function://public/default/${PACKAGE_NAME}@${PACKAGE_VERSION}'
Since Pulsar doesn’t support NodeJs runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "nodejs"}' to make it work.
The function is assumed to be already uploaded at this point. If you have not
uploaded the function, change the url parameter to be your local filepath.
This will look something like the following.-F 'url=file://$YOUR_LCOAL_FUNCTION_FILE'
You should see something like this:Replace the placeholder variables with the actual values that you can get when setting up client tools.
WEB_SERVICE_URL: the HTTPS service URL of your Pulsar cluster.
TOKEN: a valid token to interact with your Pulsar cluster.
FUNCTION_NAME: the name of your function.
FUNCTION_VERSION: the version of your function you want to deploy e.g. 1.12.