Issue calling Cloud Function (Python 3.7) runtime from Apigee - python-3.x

I have created a very simple hello-world cloud function in Python 3.7. This function works fine when I call it directly from browser, or in testing mode, or via any other client.
Invoking same function using Google Apigee cloud function extension returns an error 400 Bad Request, The browser (or proxy) sent a request that this server could not understand. This error is getting generated on request.get_json line within cloud function.
What is different between invoking Cloud function via Apigee and how to resolve this error?
(Google cloud function is default hello-world python 3.7 sample)

Related

How to create a nodejs AWS lambda function locally using vscode and not serverless or SAM CLI?

I've go through hundreds of blogs/videos/resources but nowhere it mentions how to create a simple lambda function for Nodejs REST API locally using vscode, AWS toolkit extension and AWS cli. Is there any way where I can create a simple nodejs endpoint on my local and run using above and not serverless or SAM?( There's some internal restrictions hence I can't use them)
What you need is to set up a API gateway and event trigger for your lambda that triggers whenever a HTTP request comes in. So here are steps
Look into serverless framwork where you will define a serverless.yaml file that will have configuration to mention how your lambda will get invoked (In this case, its a HTTP event)
In your IDE of choice, use serverless-offline npm package
Your IDE config will look something like this (This example uses IntelliJ IDE)
IDE config to start up Lambda in local
Once you start up the service in local, you should be able to hit the REST endpoint in local using any rest client like Postman
Instead of (4) above you could also directly invoke your lambda function in local using AWS CLI like aws lambda invoke /dev/null \ --endpoint-url http://localhost:3002 \ --function-name <Your lambda function name> \ --payload '{<Your payload>}'

How to deploy AWS Lambda Function Correctly

Using serverless, I am trying to deploy a lambda function through AppSync. I see that my function gets deployed in the AWS Console, however, it is showing that it's over 50MB and can't display the inline editing. How do I properly deploy my lambda function?
Here's what the console looks like.
Like #LLL said, the lambda function has already been deployed. One way you can confirm that is by going to your CloudFormation stack and check the status of the lambda function. If it's successfully deployed the status should be CREATE_COMPLETE or UPDATE_COMPLETE.
If you would like to view the deployed function, you can click the Actions dropdown the page you visited in the image and click Export function. This will download all the files deployed with your lambda function.

How to automate file upload on browserstack using nightwatch node js

I am writing automation using Nightwatch node js. I have a test for uploading a file in my application and testing it locally works perfectly. However, when I test it using BrowserStack, BrowserStack cannot access the file in my local machine.
I have also tried setting FileDetector but it gives error saying setFileDetector is not a function on browser object.
I know this function is available for selenium driver object but I am javascript browser object for writing test scripts.
browser.setFileDetector(new remote.FileDetector());
I see that you want to perform the File Upload Operation for a file available on your local machine. You can review the link: https://www.browserstack.com/automate/node#enhancements-uploads-downloads for more details.

How to deploy basic python functions (with packages) on Google Cloud Functions

I am attempting to deploy a basic python function which calls an api using an HTTP trigger through Google Functions (browser-editor).
Here's the function I'm trying to deploy:
import requests
import json
def call_api():
API_URL = 'https://some-api.com/v1'
API_TOKEN = 'some-api-token'
result = requests.get(API_URL+"/contacts?access_token="+API_TOKEN).json()
print(result)
call_api()
My requirements.txt contains:
requests==2.21.0
However, every time I try to deploy the function, the following error occurs:
Unknown resource type
What am I doing wrong? The function works just fine on my local machine.
Please refer to Writing HTTP Functions for more information. This is what comes to my mind when looking at your code:
Missing the request parameter (def call_api(request):)
Missing return at the end (you don't need to print it, just return it to the caller)
Calling call_api() at the end of the file will call the function only locally, CFs don't need this
Make sure you are deploying using gcloud functions deploy call_api --runtime python37 --trigger-http

Cloud Functions for Firebase error: "400, Change of function trigger type or event provider is not allowed"

When I run firebase deploy I get this error message:
functions: HTTP Error: 400, Change of function trigger type or event provider is not allowed
TL;DR
firebase functions:delete yourFunction // this can be done via the Firebase Console as well
firebase deploy
Explanation
Basically, Cloud Functions expects the same trigger for every function all the time, i.e. once it is created it has to stick to its original trigger because every function name is connected to a specific trigger. The trigger can therefore only be changed by deleting the function first and then creating it again with a different trigger.
This can now be done easily by using the functions:delete command:
firebase functions:delete yourFunction
The documentation features more advanced use cases as well.
Old solution
Solution of this is basically commenting or cutting out your function and then saving the Functions file and deploying. The function will get deleted in Firebase, but after that you can insert/uncomment your function and it will deploy just fine again. This error occurs when you take a function and change the type of trigger that it uses, i.e. HTTP, database or authentication.
Firstly cut it out
/* exports.yourFunction = someTrigger... */
And then, after deploying ("firebase deploy") replace your trigger
exports.yourFunction = anotherTrigger...
For those who stumble upon this in the future, the Cloud Functions console now offers a delete button.
You can also go to the Cloud Functions panel in the Google Cloud Platform console and delete your function from there. After that you can upload the function normally from firebase CLI. Not sure why they don't have a delete function option in the firebase console.

Resources