Question

Difficulty: EasyDeploying Serverless Applications with Cloud Run and Cloud Functions

An engineer wants to deploy a new microservice to Google Cloud Run directly from source code using the gcloud CLI. Arrange the following steps in the correct chronological sequence required to execute this deployment.

  1. 1Enable the Cloud Run API (run.googleapis.com) and Cloud Build API (cloudbuild.googleapis.com) for the project.
  2. 2Set the target Google Cloud project in the gcloud CLI using `gcloud config set project PROJECT_ID`.
  3. 3Execute `gcloud run deploy SERVICE_NAME --source .` from the local source code root directory.
  4. 4Specify the target deployment region and confirm public ingress permissions when prompted.

Answer

The correct sequence for deploying a Cloud Run service from source code is: 1) Enable Cloud Run and Cloud Build APIs, 2) Set the active GCP project context using `gcloud config set project`, 3) Run `gcloud run deploy SERVICE_NAME --source .` from the source root, and 4) Select the region and configure access permissions.
The correct deployment sequence starts with enabling the necessary service APIs (Cloud Run and Cloud Build). Next, the developer sets the target active project using `gcloud config set project`. Then, running `gcloud run deploy --source .` builds the container image and initiates deployment. Finally, configuring the deployment region and ingress permissions completes the service initialization.

Step-by-Step Solution

1
Enable required APIs
Cloud Run and Cloud Build services are active and ready to accept calls.
Deploying from source requires Cloud Build to build the container image and Cloud Run to host it.
2
Configure gcloud project property
The CLI is targeted at the intended GCP project.
Prevents deploying resources into an incorrect default project.
3
Initiate source-based deployment
Source code upload and container build pipeline are triggered.
The `--source .` flag instructs Cloud Run to use Cloud Build automatically.
4
Configure deployment options
Service is deployed to the chosen region with desired authentication settings.
Final runtime parameters are set to establish endpoint accessibility.

Key Concept

Deploying Cloud Run Services from Source Code using gcloud CLI
Rate this question