I am testing node js app using mocha and assert.
Get sample code from this link
I deploy helloBackground function in local and also in gcloud succesfullly
then I try to execute mocha test case.
also tried all way to call gcloud functions describe here
Then execute below command in CMD
functions call helloBackground --data '{\"name\": \"John\"}'
This should return "Hello John!" in command prompt.
but I receive an error as
Error: TypeError: Cannot read property 'name' of undefined
Please let me know how to pass proper data in CMD to test.
Thank you in advance.
Looking at your error message, it is most likely caused by the trigger argument you used when you deployed the app. The helloBackground function is a Background Function, and instead of --trigger-http, you should use a background function trigger.
For example: $ gcloud functions deploy helloBackground --runtime nodejs6 --trigger-resource you_bucket_name --trigger-event google.storage.object.finalize
You would need to create an empty .txt file in the same directory of your app and upload it to Cloud Storage
$ gsutil cp test.txt gs://[ the name of your cloud storage bucket ]
And you can run the app again.
You will find more explanation on the type of functions here
And you can follow this well documented tutorial on Cloud Storage here
Related
I'm trying to start a headless chrome with a puppeteer in Azure Functions on Linux.
What do I do? I have a “Function App” that looks this way:
And I have a function:
I build this function remotely this way:
func azure functionapp publish {appname} --build remote
And this is what I get when I try to run a function:
Result: Failure
Exception: Failed to launch the browser process!
/home/site/wwwroot/node_modules/puppeteer/.local-chromium/linux-1011831/chrome-linux/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory
I've seen this topic already (Puppeteer throws launch exception when deployed on azure functions node on Linux) but they recommend do a remote build, which I do and it still doesn't help.
Maybe I'm using wrong App Service Plan, but I checked and there were nothing related to special linux setup there.
The reason was that I was indeed using the wrong App Service Plan. I needed a “Function App” one. When I recreated a function with the right service plan, everything worked just fine.
I was able to deploy the azure function without the use of func azure functionapp publish {appname} --build remote. I did it using the visual studio code.
But before that I installed the puppeteer inside the function folder using
npm install puppeteer
Then I added the node_modules name in the .funcignore file.
Then I added the following setting in setting.json in the .vscode folder
"azureFunctions.scmDoBuildDuringDeployment": true
Then deploy the function normally through vscode
I have a function in my Lambda named my-s3-function. I need to add this dependency to my Lambda Node.JS. I have followed this part to update the script with dependency included (though, I didn't follow the step wherein I need to zip the folder using zip -r function.zip . but instead I zip the folder by right-clicking it on my PC).
The zip file's structured like this inside:
|node_modules
|<folders>
|<folders>
|<folders>
... // the list goes on
|index.js
|package_lock.json
Upon typing the code aws lambda update-function-code --function-name my-s3-function --zip-file fileb://function.zip to the terminal, I get the following response:
An error occurred (MissingAuthenticationTokenException) when calling the UpdateFunctionCode operation: Missing Authentication Token
What should I do to resolve this?
Based on the comments , this got resolved by configuring the credentials as described in the documentation.
Try first with exporting the credentials as described Environment variables to configure the AWS CLI. Once you are sure your credentials are correct then you can follow this Configuration and credential file
I am trying to deploy my nodejs application to cloud run using the following command
gcloud run deploy --image gcr.io/[project-id]/helloworld --platform managed
Before running this command I built two cloud build images and trying to deploy the latest build using above command. But getting the following error
ERROR: (gcloud.run.deploy) Error parsing [service].
The [service] resource is not properly specified.
Failed to find attribute [service]. The attribute can be set in the following ways:
- provide the argument [SERVICE] on the command line
- specify the service name from an interactive prompt
I don't know which is causing error. Can anybody help me with this? Thank you
Try specifying the Service ID as an argument, replacing my-service with the desired name:
gcloud run deploy my-service --image gcr.io/[project-id]/helloworld --platform managed
Also, make sure you're using the latest Cloud SDK with gcloud components update.
$ gcloud run deploy --image gcr.io/cloudrun/hello --platform managed should prompt you to pick a platform, pick a region and a service name. Please try with this command.
In your command, make sure to replace [project-id] with you GCP project ID.
I can able to deploy my serverless app on aws lambda using command
sls deploy, and this is working fine but when i try to debug using below command from command line
SLS_DEBUG=* sls deploy
its showing
SLS_DEBUG' is not recognized as an internal or external command
Note - I'm using window 10
SLS_DEBUG is an environment variable, therefore if you use windows - you have to set it in a windows way. In powershell, for example, it would look like this:
$env:SLS_DEBUG = '*'; sls deploy
I'm using Windows 7x64, gcloud installed version
Google Cloud SDK 0.9.71
app 2015.07.24
app-engine-java 1.9.24
app-engine-python 1.9.24
app-engine-python-extras 1.9.21
bq 2.0.18
bq-win 2.0.18
core 2015.07.24
core-win 2015.07.24
gcloud 2015.07.24
gsutil 4.13
gsutil-win 4.13
preview 2015.07.24
windows-ssh-tools 2015.06.02
I'm trying to run on preview and deploy the tutorial example from here. Note that app.yaml from this example has "nodejs" set as runtime.
After running command
gcloud preview app run --host localhost:8080 app.yaml
I get
RuntimeError: Unknown runtime 'nodejs'; supported runtimes are 'custom', 'go', 'java', 'java7', 'php', 'php55', 'python, 'python27', 'vm'.
If I put "vm" for runtime it wants to use docker, which doesn't work for me either and I wanted to use the option to do this without docker anyhow.
If I put "custom" for runtime in yaml file I get:
ValueError: The --custom_entrypoint flag must be set for custom runtimes
Example given in the help output for this switch is the following
--custom_entrypoint="gunicorn -b localhost:{port} mymodule:application"
I tried with this, best guess
gcloud preview app run --custom_entrypoint="nodejs -b localhost:{8080} mymodule:application" app.yaml
and got this
ERROR: Argument [--custom_entrypoint=nodejs -b localhost:{8080} mymodule:application] is not a valid deployable file.
ERROR: (gcloud.preview.app.run) Errors occurred while parsing the App Engine app configuration.
Thanks for your time.
The gcloud command seems to be undergoing some changes, so this question seems no longer valid, since we're meant to run dev_appserver.py instead of gcloud to run devserver processes; you can also just straight-up run the node server, or even use docker to build the image from your dockerfile and run that as a container.
If running from dev_appserver.py, make sure you have runtime: custom and a Dockerfile sourcing FROMgcr.io/google_appengine/nodejs, since dev_appserver.py currently raises:
RuntimeError: Unknown runtime 'nodejs'; supported runtimes are 'custom', 'go', 'java', 'java-compat', 'java7', 'php55', 'python', 'python-compat', 'python27'.