Synapse Workspace Notebooks - Upload files to sparkpools for google api credentials

Ana Del Campo 121 Reputation points Microsoft Employee
2020-11-12T15:09:08.453+00:00

I am working with Synapse Workspace Notebooks to import information from google API's. I need to upload credential files to the local directories on the synapse spark pools, I have not been able to figure out how to do that

Uploading to azure storage and pointing the files from there won't when using google python provided libraries look at the local computer storage.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
{count} votes

Accepted answer
  1. Ana Del Campo 121 Reputation points Microsoft Employee
    2020-11-16T05:09:02.813+00:00

    I am working with py.drive, I found a good work around that will do for now. In the notebook, I created a variable with the credentials then saved the credentials to the nodes. But I had no problem doing this on databricks, but synapse notebooks not the best way to do it.

    CREDENTIALS = '{"web":{"client_id":"xxxxxxx.....}'

    SECRETS = '{"installed":{"client_id":"xxxxxxxx.....}}'

    MYCREDS = '{"access_token": "xxxxxxxx....."_module": "oauth2client.client"}'

    import json
    creds = json.loads(CREDENTIALS)
    with open('credentials.json', 'w') as outfile:
    json.dump(creds, outfile)

    secrets = json.loads(SECRETS)
    with open('client_secrets.json', 'w') as outfile:
    json.dump(secrets, outfile)

    mycreds = json.loads(MYCREDS)
    with open('mycreds.txt', 'w') as outfile:
    json.dump(mycreds, outfile)

    from there I was able to continue with authentication code and so on.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. David Browne - msft 3,851 Reputation points
    2020-11-13T21:47:41.57+00:00

    You can use the normal python file APIs to interact with the actual filesystem on the node running the python code (the driver usually, but could be a worker if you are using a python UDF).

    You may not be able to write a file to the location you need due to file permissions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.