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.
- 1Enable the Cloud Run API (run.googleapis.com) and Cloud Build API (cloudbuild.googleapis.com) for the project.
- 2Set the target Google Cloud project in the gcloud CLI using `gcloud config set project PROJECT_ID`.
- 3Execute `gcloud run deploy SERVICE_NAME --source .` from the local source code root directory.
- 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
Key Concept
Deploying Cloud Run Services from Source Code using gcloud CLI