Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You are deploying a new revision of an existing Cloud Run service named order-processor directly from a local source code directory that contains a Dockerfile. The existing service already has several runtime environment variables configured that must be preserved.
You need to configure the deployment to meet the following requirements:
order-sa@my-project.iam.gserviceaccount.com.CACHE_TTL=300 without removing existing runtime environment variables.2 vCPUs and 4Gi of memory per container instance.Which gcloud command or workflow should you use?
gcloud run deploy order-processor --source=. --service-account=order-sa@my-project.iam.gserviceaccount.com --update-env-vars=CACHE_TTL=300 --cpu=2 --memory=4GiUsing gcloud run deploy with --source=. executes Cloud Run's source-to-service workflow, automatically building the container image from the local Dockerfile via Cloud Build, pushing it to Artifact Registry, and deploying a new immutable revision with the specified runtime flags.
--source=. flag detects the Dockerfile in the local directory and builds and deploys the service in one command.--service-account flag attaches order-sa@my-project.iam.gserviceaccount.com as the service identity of the new revision, governing what Google Cloud resources the running application can access.--update-env-vars=CACHE_TTL=300 flag performs a non-destructive update, adding or updating CACHE_TTL while keeping all existing runtime environment variables intact.--cpu=2 and --memory=4Gi satisfies Cloud Run's resource rules, where 2 vCPUs supports up to 8 GiB of memory and 4Gi meets the minimum 512 MiB requirement for the second-generation execution environment.2 vCPUs avoids fractional-CPU restrictions such as forced concurrency of 1.This command combines the exact source deployment, service identity, non-destructive environment variable, and valid compute limit flags supported by gcloud run deploy in a single step.
serviceAccountName, CACHE_TTL environment variable, 2 vCPUs, and 4Gi memory limit in a service.yaml file without an image field, and run gcloud run services replace service.yaml from the source directory.gcloud run services replace doesThe gcloud run services replace command applies a Knative-compliant declarative YAML specification (service.yaml) to create or update a Cloud Run service using a pre-existing container image.
service.yaml file cannot be used to build and deploy from source code because the container image path (image) is a mandatory element in the specification.gcloud run services replace only updates the Cloud Run service configuration from the YAML file; it does not package local source files, invoke Cloud Build, or build a Dockerfile.service.yaml.gcloud run services describe --format export first so existing environment variables are not unintentionally dropped.You already had a built container image stored in Artifact Registry and wanted to manage runtime configuration declaratively using a Knative YAML manifest rather than deploying directly from local source code.
For source-to-service workflows (--source), configuration must be passed using gcloud run deploy flags because the final container image URI does not exist prior to the build step.
gcloud run deploy order-processor --source=. --build-service-account=order-sa@my-project.iam.gserviceaccount.com --set-build-env-vars=CACHE_TTL=300 --cpu=2 --memory=4GiThe --build-service-account and --set-build-env-vars flags configure the build-time environment used by Cloud Build and buildpacks when creating a container image from source code, rather than configuring the runtime environment of the deployed Cloud Run revision.
--build-service-account specifies which service account executes the Cloud Build job. It does not change the service identity attached to the running Cloud Run revision, so the service continues running under its previous or default service account.--set-build-env-vars flag injects variables into the buildpacks build process (for example, to customize compiler options). Those variables are not injected into the running container at runtime, and because the directory uses a Dockerfile, buildpack variables do not configure the application's runtime settings.--source deployments and do not persist as runtime configuration on the revision.--set-build-env-vars replaces all existing build environment variables rather than performing a non-destructive update.roles/run.builder, whereas the runtime service identity needs permissions to access Google Cloud APIs used by the app.You needed to customize the Cloud Build execution identity and pass build-time configuration arguments to Google Cloud buildpacks without modifying the running service's identity or runtime environment variables.
gcloud run deploy order-processor --source=. --service-account=order-sa@my-project.iam.gserviceaccount.com --set-env-vars=CACHE_TTL=300 --cpu=0.5 --memory=4GiThis command deploys from source with the correct service identity flag (--service-account), but it uses a destructive environment variable flag (--set-env-vars) and an invalid CPU-to-memory allocation (0.5 vCPU with 4Gi of memory).
--set-env-vars flag removes all existing runtime environment variables on the service before setting CACHE_TTL=300, violating the requirement to preserve previously configured variables.0.5 vCPU configuration supports a maximum of 1 GiB of memory, so requesting 4Gi with --cpu=0.5 fails validation.1 vCPU is required to configure more than 1 GiB of memory (up to 4 GiB), and 2 vCPUs supports up to 8 GiB.1 vCPU also forces maximum concurrency to 1, requires request-based billing, and restricts the service to the first-generation execution environment (gen1).--update-env-vars, --set-env-vars acts as a full reset of runtime environment variables.You wanted to intentionally wipe all existing runtime environment variables and deploy a lightweight, single-concurrency service requiring 0.5 vCPU and 1Gi or less of memory.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated