Google Cloud Function - google-cloud-platform

I am following the google tutorial on creating a simple helloWorld function and deploying it on google cloud. My machine is Windows 7 - 64 bit.
I am following this link: https://cloud.google.com/functions/docs/tutorials/http
However I am facing few issues here:
1. Before You Begin -> Enable the API: getting the following error: "You have no permissions to use requested API"
2. Install the Cloud SDK: When I run the downloaded installer, following error comes: "Unzip failed: Error opening ZIP file"
I however installed SDK from another link:
https://cloud.google.com/sdk/downloads#versioned
3. Unable to install alpha component. Used this command:
gcloud components install alpha
4. Deploying the function:
ERROR: (gcloud.alpha.functions.deploy) ResponseError: status=[403], code=[Forbid
den], message=[Cannot access Google Cloud Functions API in project gcf-project-1
]
If anybody knows the solution, please help.
Thanks,
Robin

it might be silly but be sure to enable the cloud functions api in your project settings on the gcloud dashboard website.

Google Cloud Functions was just released as public beta. The commands are slightly different (e.g. you don't install alpha components)! It should all work now without whitelisting.
https://cloud.google.com/functions/

Google Cloud Functions is currently in Alpha, which means it's whitelist only. You're getting this error because your account is not whitelisted. You'll need to sign up for access to the Alpha, which you can do here

Related

Actions on Google - CLI (gactions) comment not found

This questions maybe already asked but that is not solve my issue.
I'm trying to deploy my gactions script in google cloud function. So for that I have installed the gactions CLI in Ubuntu 20.04 machine, but I'm having some problems.
The mentioned gactions CLI comments not working in terminal, it's shows [ERROR] unknown command "test" for "gactions" error message.
Eg: gactions test --action_package action.json --project PROJECT_ID
Am using gactions version 3.2.0. Please suggest me how to use those comments in terminal.
I have tried with sudo gactions test --action_package action.json --project PROJECT_ID that also not working.
As the error [ERROR] unknown command "test" for "gactions" describes that the test command is not validating by the gactions CLI.
Might be due to below reasons, can you you have a check on this :
As per this official doc , you are trying to execute the text command
but make sure the action package name given by you is correct.
Can you try any other arguments mentioned in the gactions supported
arguments doc and have a try whether those are validating or not.
Enable the Actions API in the Google Cloud console by following the
instructions in Enable and disable APIs. This allows gactions to
interact with your project.
Make sure you have installed the gactions CLI correctly by running
the command 'gactions version' to check the version number. If the
version number matches the version you installed, then the CLI is
probably installed correctly. If not reinstall the CLI using this
gactions overview

Unable to push to Google Container Registry - Permission issue

I'm having the sample problem as Vaclav. I've followed the GCR quick start to the letter which entailed creating a new project (called gcr-project) and copying the code for a Flask (python) app.
After building the docker image, I entered the commands:
gcloud auth configure-docker
docker tag quickstart-image gcr.io/gcr-project/quickstart-image:tag1
docker push gcr.io/gcr-project/quickstart-image:tag1
The response was:
unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
So it would be nice to know if the issue is with the credentials (I'm using cloud SDK OK for other projects) or permissions. The documentation here suggests you need storage-admin rights but the projects already has it, see screen cap here
Would appreciate any tips for trouble shooting this as I was looking for to using the GCR but this problem is a hard stop for me.
UPDATE:
I tried the same process with the cloud shell
me#cloudshell:~ (gcr-project-XXXXXX)$ docker push gcr.io/gcr-project/quickstart-image:tag1
The push refers to repository [gcr.io/gcr-project/quickstart-image]
4399528b7213: Preparing
1d10b1eeca74: Preparing
75156020d862: Preparing
c5697656a146: Preparing
2a435270de82: Preparing
c35f70b5c25a: Waiting
28e260baaf1b: Waiting
556c5fb0d91b: Waiting
denied: Token exchange failed for project 'gcr-project'. Please enable Google Container Registry API in Cloud Console at https://console.cloud.google.com/apis/api/containerregistry.googleapis.com/overview?project=gcr-project before performing this operation.
me#cloudshell:~ (gcr-project-XXXXXX)$
This prompted me to check the API & Services dashboard to confirm the container-registry API was enabled - It is.
UPDATE 2:
I'm having these problems on a machine running ubuntu 19.04. Per the comments below I was able to do a push via the cloud shell. So I then went through the same exercise on a MacBook Pro - worked no problems.
So I then uninstalled Cloud SDK per the doco having used the standard linux install instructions previously. I then re-installed using the debian-ubuntu install instructions (version 274.0.1-0)... STILL no go.
When I do a docker pull on the image (because push worked on MBP) I get this error: Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
And when I do a push I get this error: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
So at this stage, given the success on the MBP and the lack thereof on the linux/ubuntu machine, the problem is constrained to to linux/ubuntu installs.
UPDATE 3:
I got on to a separate ubuntu server, did a clean install with sudo snap install google-cloud-sdk --classic , did everything else per the docs and still had the exact same problem. So I recon this is a linux google cloud SDK specific problem.
Is there anyone out there Ubuntu land who as been able install and use cloud SDK with GCR recently?????????
I was able to replicate this issue on multiple ubuntu machines. I tried again after the most recent cloud SDK update (276.0.0) but had no luck.
In the end I went with json key file authentincati described in the docs here as a work around which worked fine.

gcloud crashed (SSLHandshakeError) in gcloud app deploy

Unable to deploy my app as I started getting below error since today morning.
I have tried gcloud info --run-diagnostics and gcloud components reinstall without much help.
I tried to deploy it using the old Google App Engine Launcher for Windows but faced the same error.
Earlier it worked till yesterday night (IST) using gcloud. Please help!
I am on latest gcloud sdk and have updated all its components. I use Win10. I tried rebooting my laptop as well.
C:\gaurav\coding\python\myapp\myapp\dist>gcloud app deploy --project=myproject --version 1 --verbosity=info ./app.yaml
INFO: Refreshing access_token
ERROR: gcloud crashed (SSLHandshakeError): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)
If you would like to report this issue, please run the following command:
gcloud feedback
To check gcloud for common problems, please run the following command:
gcloud info --run-diagnostics
C:\gaurav\coding\python\myapp\myapp\dist>
Diagnostics Output.
C:\gaurav\coding\python\myapp\myapp\dist> gcloud info --run-diagnostics
Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
ERROR: Reachability Check failed.
Cannot reach https://accounts.google.com (SSLHandshakeError)
Cannot reach https://cloudresourcemanager.googleapis.com/v1beta1/projects (SSLHandshakeError)
Cannot reach https://www.googleapis.com/auth/cloud-platform (SSLHandshakeError)
Network connection problems may be due to proxy or firewall settings.
Do you have a network proxy you would like to set in gcloud (Y/n)? n
ERROR: Network diagnostic (0/1 checks) failed.
C:\gaurav\coding\python\myapp\myapp\dist>
Although gcloud info --run-diagnostics complains that the three URLs are not reachable. I am able to open them from web browser.
I found that when using Fiddler (for viewing network traffic) and have decrypting https traffic enabled, then I received the SSLHandshakeError.
Stopping the tool (or choosing not to decrypt https traffic) and then running the gcloud resulted in success.
According to the comments, also a problem with other web debugging proxies such as Charles.
A problem in recent GAE and GCloud SDK versions is the presence of invalid SSH certificates, see, for example, Google App Engine SSL Certificate Error and issue 38338974.
You could try to use my suggested solution in the above-mentioned post and replace your SDK's certificate file with a valid one (will have to locate a good one for the gcloud SDK, my answer was for the GAE SDK).
You might also be able to use the gcloud config command to set the core custom_ca_certs_file configurable property to point to a file with up to date certificates, if you have one. I didn't try it, YMMV.
Upgrading to Python 2.7.9 on MacOS High Sierra solved the issue for me.
I had this issue upon install of the google cloud SDK on MacOS Mojave. I am not behind a corporate proxy, and all the answers on the web seemed to indicate that this was the issue. I noticed in the install.sh script that it takes an environment variable CLOUDSDK_PYTHON for the python executable. So, I fixed this by exporting the path to my python 3 executable.
In my case:
export CLOUDSDK_PYTHON=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
The install worked as expected after this.
On MacOS Catalina, the solution was to completely uninstall gcloud and reinstall it.
I had the same issue, downloaded the root/intermediate cert from one of the google url you get when you run the command: gcloud info --run-diagnostics and append to the cacerts.txt file that is being used. In my case it was the following one: google-cloud-sdk/lib/third_party/httplib2/python2/httplib2/cacerts.txt
For me it was a conflict in the python versions. gcloud was calling a different version. The solution was to set CLOUDSDK_PYTHON to point to the correct python (python2 in this case).
I tried to deploy gcloud and I was getting this error. Here is how I fixed it:
Access to Google cloud using Firefox
Download certificate. pem file and chain file
Append them on cert.pem located at:
C:\Program Files\google-cloud-sdk\lib\third_party\certifi\cert.pem
(using this you are creating custom CA cert file based on your proxy)
Update cert file as mentioned here: https://cloud.google.com/sdk/gcloud/reference/config/set
(Absolute path to a custom CA cert file.)
Make sure you have cert.pem at the end of path.
I fixed the problem by installing gcloud from apt-get. The guide is at this link

SSH Error while trying to connect to Google Compute Instance

I am running below command to connect to google compute instance:
gcloud compute ssh example-instance
I am getting error message below:
ERROR: (gcloud.compute.ssh) Your platform does not support OpenSSH.
Can someone please help me in this regard.
Thanks
Shiv
Try updating your local Cloud SDK and run ssh command again. To update the Google Cloud SDK use the following command:
gcloud components update
The error is pretty much self-explanatory. You need to install an OpenSSH to operate. Try installing OpenSSH. The guide for installing on Windows 10 is as follows:
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

What are the necessary steps for deploying application on micro-cloud-foundry?

I want to configure the cloudfoundry environment correctly and test some small application. If any one know, please help me to configure this environment correctly and let me know any use full reference document is available for this, thanks a lot.
I have registered with cloudfoundry and got downloaded following stuffs:
1) micro-1.2.0.zip
2) VMware-Player-4.0.2-591240.x86_64.bundle
3) springsource-tool-suite-2.9.1.RELEASE-e3.7.2-linux-gtk-x86_64.tar.gz
You have everything you need. In short you will need to:
Install Ruby and then VMC or STS plugin for CF
Install VMWare player and run the micro instance within it. Basically you will open the *.vmx file in micro through VMWare player. Your machine has to support and enable virtualization for this
Do necessary configurations and validate your CF with token received online when you created account and domain
open vmc and change target to point to local CF use command "vmc target CFM_ADDRESS"
Deploy and test your application
You can follow this tutorial if it helps you: http://cloudspring.com/get-in-the-cloud-with-cloudfoundry/