Authenticating the service account

Import the following namespaces to the project in the Program.cs file of the solution. This code sample is available on GitHub at the following URL: https://github.com/hthirukkumaran/Learning-Google-BigQuery:

using Google.Apis.Auth.OAuth2;
using Google.Apis.Bigquery.v2.Data;
using Google.Cloud.BigQuery.V2;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

Add the following code to the main method of the program.cs file to create a client instance of BigQuery service. Refactor this code to remove the hardcoded file path, application name, and more logging as per your requirement. Use the project ID, not the project name, of your Google Cloud project.

If the credential is to be shared with other applications, then it is better to create an environment variable with the name GOOGLE_APPLICATION_CREDENTIALS and set the path of the .json file as a value for this environment variable. When creating the BigQueryClient object, pass only the project ID.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.131