Javascript required
Skip to content Skip to sidebar Skip to footer

How to Install Google Cloud Sdk in Windows

How To Install And Configure Google Cloud SDK Or gcloud On Windows OS

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In this blog post, we will discuss how to install and configure Google cloud SDK or gcloud on windows OS. The gcloud command-line interface is a tool that provides the primary CLI to Google Cloud Platform. You can use this tool to perform many common platform tasks either from the command-line or in scripts and other automation.

What is gcloud?

The gcloud CLI is a part of the Google Cloud SDK. You must download and install the SDK on your system and initialize it before you can use the gcloud command-line tool.

By default, the SDK installs those gcloud CLI commands that are at the General Availability level only. Additional functionality is available in SDK components named alpha and beta. These components allow you to use the gcloud CLI to work with Google Cloud Bigtable, Google Cloud Dataflow and other parts of the Cloud Platform at earlier release levels than General Availability.

Google provides gcloud interface directly in your browser which is preinstalled and preconfigured. To access your gcloud interface from browser you can simply login to your cloud console and click on 'Activate cloud shell'.

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

But if you want to use gcloud from a remote system or from a compute instance, you need to install and configure your gcloud tool.

How to install gcloud on Windows OS:

Prerequisite for gcloud:

  • A GCP account with at least one project and proper access.

Step 1: Log in to your windows system and download the latest version of Google cloud SDK using the below link.

https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe

Step 2: Double click on the downloaded installer and click on "Run".

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Step 3: Follow the installation wizard and click 'Install' to install Google Cloud SDK on your system.

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Click on 'Finish' once the installation is completed.

Step 4: Validate the installation by executing the below command on the command prompt.

If you get the gcloud version that means your installation was successful. Next, we are going to configure gcloud.

How to configure gcloud on Windows OS:

There are two ways to configure gcloud, user account-based, and service account-based.

  • gcloud auth login: Authorize with a user account without setting up a configuration.
  • gcloud auth activate-service-account: Authorize with a service account instead of a user account.

The user account based gcloud initialization requires you to authenticate on a browser. If you using an operating system without browser, you can take the service account based gcloud initialization. We will provide a demo for both options.

User account based gcloud configuration:

Step 1: Open your default web browser and login to the google account that you are using to access your Google cloud console.

Step 2: Open the command prompt and type the below command to initialize gcloud.

It will open your default web browser and ask you for authorization, click 'Allow'.

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

This will create the default configuration file for your gcloud in C:\Users\<UserName>\AppData\Roaming\gcloud location.

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Step 3: You can view your configuration details using below command

gcloud config configurations list

Next, we are going to configure the project and default region and zone for compute services for our gcloud.

Step 4: Configure your GCP default project, region, and zone for compute services.

## configure default project

gcloud config set project < YOUR_PROJECT_NAME >

## configure default region for compute service

gcloud config set compute / region < YOUR_REGION_CODE >

## configure default zone for compute service

gcloud config set compute / zone < YOUR_ZONE_CODE >

## get current configuration details

gcloud config configurations list

## execute your 1<sup>st</sup> gcloud command

gcloud compute networks list

Note: All the default configuration can be overridden by the gcloud global flags.

Next, we are going to create a custom configuration for gcloud using a service account.

Service account-based gcloud configuration:

Step 1: Create a service account for gcloud

Login to the GCP console and click on 'IAM & admin' > 'Service accounts'

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Click 'CREATE SERVICE ACCOUNT'

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Provide a name to your service account and click 'CREATE'

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Provide access to your project to the service account

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Create a key file and click 'DONE'

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

How To Install And Configure Google Cloud SDK Or Gcloud On Windows OS

Note: One key file with .json extension will be downloaded automatically, keep this file in a safe location. We will use this key file during gcloud configuration.

Step 1: Open a command prompt and execute the below command to configure gcloud using a service account.

gcloud auth activate - service - account < YOUR_SERVICE_ACCOUNT > ^

-- key - file = < YOUR_KEY_FILE > .json ^

-- project = < YOUR_PROJECT >

Step 2: Confirm if gcloud configured successfully.

## get current configuration details

gcloud config configurations list

## execute your 1<sup>st</sup> gcloud command

gcloud compute networks list

Hope you have enjoyed this blog post. You can refer to the official documentation to get more details on Google cloud SDK and gcloud.

https://cloud.google.com/sdk/docs/install

https://cloud.google.com/sdk/docs/initializing

https://cloud.google.com/sdk/gcloud/reference

How to Install Google Cloud Sdk in Windows

Source: https://cloudaffaire.com/how-to-install-and-configure-google-cloud-sdk-or-gcloud-on-windows-os/