Create a New Cloud Function from Git Cloud Source Repository

The objective of this step-by-step tutorial is to create and deploy a new Google Cloud Function from a local Windows 10 computer, and host the code in a Source Code Repository.

Install the Required Windows Dependencies

Install Git

Download from https://git-scm.com/downloads

If it is OK, try the following command in CMD

git version

Install NodeJS/NPM

Download from https://nodejs.org

To see, try the following command in CMD

npm version

New Git and NPM Project Initialization

Init New GIT Repository

Create a new project folder and init the GIT local repository

init git repository

Init NPM Project

Set the different parameters with your values (or the default ones). They could all be changed later.

At this point, it is possible to add the remote GIT repository, but we will do it in a next separated step.

When the process ends, your project folder should contain the package.json file.

Create NodeJS Entry Point

Create the fil in the prject folder, with you favorite text editor or EDI. With the Following example content :

GIT Operations

Add the files to Commit

Add all files at once

O add file by file

(Optional) Configure GIT User

If GIT has just been installed and this is the first use, you should configure th user name and email.

Commit the Code in the Local Git Repo

git commit npm

Google Cloud Source Code Repository

google cloud source code repository

Create a new repository

create new google cloud source code repository

Setup SSH Key

Check Windows 10 OpenSSH Configuration

Check that the Windows 10 OpenSSH client is installed

windows 10 parameters
windows 10 optional features
windows 10 enable open ssh client

Test with CMD

Generate Keys

In the Command Line

Select file location and passphrase. Your key has been generated. Default folder is .ssh in the user’s home. Copy the id_rsa.pub file’s content.

Register the SSH key with Google Cloud

Go to Manage SSH Keys

Register a new key

The key content is the content of the file id_rsa.pub

Push the Code to the Repository

Add the Remote Repository

Push

You can test by browsing to this code repository on Google Cloud

Push my Branch as Upstream branch

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *