Doug Fir
Doug Fir

Reputation: 21204

"Invoke function" gives curl: (6) Could not resolve host: undefined

In VSCode with the cloud code add on, I have a list of my active cloud functions.

When hovering over one of them there's an option "Invoke Function via http"

enter image description here

If I select this I get the following command and output:

curl -m 60 -w "\n" -X POST undefined -H "Authorization: Bearer $(gcloud auth print-identity-token)" -H "Content-Type:application/json" -d '{}'
curl: (6) Could not resolve host: undefined

How can I use this built in functionality to invoke my cloud function locally as part of development and debugging work?

Upvotes: 0

Views: 356

Answers (1)

Sebastian Krupa
Sebastian Krupa

Reputation: 116

Was this Function defined via a non-HTTP trigger (e.g. Cloud Pub/Sub, Cloud Storage)? Currently Cloud Code only supports Functions with HTTP triggers. I'm following up to make it so the button only appears on compatible HTTP functions to prevent this.

Also to clarify, Cloud Code does not currently support pure local-development. The "Invoke function via HTTP" button will make a network call to the deployed function, so any changes will need to be deployed to see the new results. For local development you can refer to these docs for setting up Functions Framework https://cloud.google.com/code/docs/vscode/setup-local-functions-dev-environment#python

Upvotes: 1

Related Questions