Soru

Zorluk: KolayDeploying Serverless Applications with Cloud Run and Cloud Functions

You are tasked with deploying a Python-based microservice to Google Cloud Functions (2nd gen) using the gcloud command-line interface. Arrange the deployment workflow steps into the correct chronological order from start to finish.

  1. 1Enable the required Google Cloud APIs, including the Cloud Functions API and Cloud Build API.
  2. 2Prepare the source code (main.py) and dependencies file (requirements.txt) in the local working directory.
  3. 3Run the gcloud functions deploy command specifying the function name, runtime, trigger, and entry point.
  4. 4Test the function by invoking its generated HTTPS endpoint URL to verify successful execution.

Cevap

The correct chronological sequence is: first, enable the required APIs; second, prepare local application files; third, execute the gcloud functions deploy command; fourth, test the deployed HTTPS endpoint.
Deploying serverless workloads on Google Cloud follows a standard linear lifecycle: project API enablement precedes local source code creation, followed by deploying via the gcloud CLI, and concluding with endpoint functional testing.

Adım Adım Çözüm

1
Enable project service APIs
Cloud Functions API and Cloud Build API are active and ready to accept requests.
Google Cloud requires required service APIs to be active before accepting deployment commands.
2
Develop code and dependency files
Source files main.py and requirements.txt are saved in the project folder.
Cloud Functions requires local source files to package during deployment.
3
Execute deployment command
The code is uploaded, built, and deployed as a 2nd gen Cloud Function.
Executing gcloud functions deploy triggers Cloud Build to compile and host the revision.
4
Verify service functionality
HTTP response confirms function execution.
Post-deployment validation ensures the endpoint works as expected.

Anahtar Kavram

Cloud Functions Deployment Workflow
Bu soruyu puanla