
Answer-first summary for fast verification
Answer: Run your script on a new virtual machine with the BigQuery access scope enabled.
The correct answer is **B** because, by default, a Google Compute Engine instance is associated with a default service account and default access scope, neither of which grants access to BigQuery. While using a service account with the appropriate IAM roles is recommended, the instance's access scopes must also be configured to allow OAuth authentication for API requests made through the gcloud tool and client libraries. Setting the full `cloud-platform` access scope on the instance and then limiting the service account's access via IAM roles is the best practice. Options A, C, and D are incorrect because they do not address the root cause of the connectivity issue, which is the lack of necessary access scopes on the instance.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Your Python script, designed to connect to Google BigQuery from a Google Compute Engine virtual machine, is failing with connection errors. What steps should you take to resolve this issue?
A
Install the bq component for gcloud with the command gcloud components install bq.
B
Run your script on a new virtual machine with the BigQuery access scope enabled.
C
Install the latest BigQuery API client library for Python.
D
Create a new service account with BigQuery access and execute your script with that user.
No comments yet.