0

i try to connect my azure function to google cloud storage and I have some issues with the authentication. I am able to connece everythin from my JupyterNotebook but in my azure function I am not able to provide the credentials as path. In my azure function I am not able to provide a path but have the credentials in a variable. It returns the error Exception: OSError: [Errno 63] File name too long. I think the error occures because it treads the credentials as path. I could not find a way to connect to google storage toll now.

Here is a super short version of what I did to get the client:

from google.cloud import storage

google_credentials = get_credentials()
client = storage.Client.from_service_account_json(google_credentials)

Any suggestions how I can connect with a service account to google within an azure function?

Best :-)

Pet
  • 251
  • 1
  • 3
  • 14
  • What is the content of `google_credentials`? What is its type? – guillaume blaquiere Aug 24 '20 at 09:49
  • Hello @guillaumeblaquiere and thanks for your answer. The type is `````` SInce this morning I worked on the problem and have an other idea where I get a different error message: ``` path_to_key = '<<>>' service_account_info = json.load(open(path_to_key)) google_credentials = service_account.Credentials.from_service_account_info( service_account_info ) client = storage.Client(credentials=google_credentials) ``` here the error message is ```DefaultCredentialsError: Could not automatically determine....``` – Pet Aug 24 '20 at 11:24
  • ```...credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started ``` the error message does not help an all because I think that I provide the credentials explicitly – Pet Aug 24 '20 at 11:29
  • You can't store file locally and temporarily on Azure Functions, like the `/tmp` directory? Anyway, if you have a path like in your previous comment, simply do this `client = storage.Client.from_service_account_json()` – guillaume blaquiere Aug 24 '20 at 11:43
  • @guillaumeblaquiere I totally agree with your answer but I do not have a path. This was only for local testing in my Jupyter notebook. I am looking for a solution where I can read the JSON from my key vault and login into google storage – Pet Aug 24 '20 at 11:51
  • The focus of the question changed a los so I decided to start a new conversation: https://stackoverflow.com/questions/63561032/how-to-log-in-google-storage-from-a-python-function – Pet Aug 24 '20 at 12:26

1 Answers1

0

Finaly I saw that the code that I am using needs a path as argument. I delivered the credentials.

Pet
  • 251
  • 1
  • 3
  • 14