A Python script on a Compute Engine VM fails to connect to BigQuery. How should you fix it?
Choose an answer
Tap an option to check your answer.
Correct answer: Create and use a service account with BigQuery permissions to execute the script.
Why this is the answer
The most secure and recommended way to grant a Compute Engine VM access to BigQuery is by using a service account. You should create a service account, grant it the necessary BigQuery roles (e.g., BigQuery Data Editor, BigQuery User), and then configure your VM to run as this service account. This ensures the script has the specific permissions it needs without over-privileging the VM. Installing the latest client library is good practice but doesn't address authentication issues. Enabling the BigQuery access scope on the VM is a broader approach that grants access to all applications on the VM, which is less granular and less secure than a dedicated service account. Installing the bq component is for using the gcloud CLI, not for programmatic access within a Python script.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed