I am trying to use bq cli to export data using big Query to GCS. Currently there are two projects and each project is having its own service account. I have authenticated the services account using gcloud auth active-service-account by passing the key json file. While running my jobs i am explicitly setting the project and account using the below commands
Within JOB1
gcloud config set account account1
gcloud config set project project1
bq extract --destination_format NEWLINE_DELIMITED_JSON table1 gs://path1
Within JOB2
gcloud config set account account2
gcloud config set project project2
bq extract --destination_format NEWLINE_DELIMITED_JSON table2 gs://path2
When both job1 and job2 are running in parallel JOB1 is failing with the error account2 not having access to project1 and similarly in some instances JOB2 is failing with the error account1 is not having access to project2. We have identified that its happening because when we set the account its changing the default account within the server(and not within the session) and therefore the other job which is running in parallel failing. Can you please help on how we can execute bq commands using multiple service accounts in parallel within the same server