BigQuery with .NET Core

Here is a sample respository ready to be injected to a ASP.NET Core application.

   public class SelfViewRepository : ISelfViewRepository
    {
        private readonly string _projectId;
        private readonly GoogleCredential _gcpCredential;

        public SelfViewRepository(string projectId, string credentialFile)
        {
            _projectId = projectId;
            _gcpCredential = GoogleCredential.FromFile(credentialFile);
        }

        public async Task<BigQueryResults> GetData(string query)
        {
            BigQueryClient client = BigQueryClient.Create(_projectId, _gcpCredential);

            BigQueryJob job = client.CreateQueryJob(
                sql: query,
                parameters: null,
                // options: new QueryOptions {UseQueryCache = false});
                options: new QueryOptions { });
            var data = await job.GetQueryResultsAsync();
            // Wait for the job to complete.
            job.PollUntilCompleted();
            // Display the results
            return data;
        }
    }

#googlecloud #bigquery #aspnetcore

Advertisements

Google Cloud Build Trigger: ASP.NET Core and Angular


steps:
# run npm install for Angular
- name: 'gcr.io/cloud-builders/npm'
  args: ['install']
  dir: 'MyProject.Web/ClientApp'
# build Angular for production
- name: 'gcr.io/cloud-builders/npm'
  args: ['run', 'build','--','--prod']
  dir: 'MyProject.Web/ClientApp'
# publish asp.net core solution  
- name: microsoft/dotnet:2.2-sdk
  args: ['dotnet', 'publish','-c','Release']
# deploy the webapi to the AppEngine
- name: gcr.io/cloud-builders/gcloud
  args: ['app', 'deploy', './MyProject.Web/bin/Release/netcoreapp2.2/publish/app.yaml','--version','staging']
timeout: 660s

Other examples:
https://stackoverflow.com/questions/52725046/google-cloud-builder-how-to-trigger-build-configuration-in-a-subdirectory

#GoogleCloud #gcp #BuildTrigger