【发布时间】:2020-08-24 05:56:30
【问题描述】:
我尝试将我的天蓝色功能连接到谷歌云存储,但我遇到了一些身份验证问题。
我可以从我的 JupyterNotebook 连接所有内容,但在我的天蓝色函数中,我无法提供凭据作为路径。在我的天蓝色函数中,我无法提供路径,但在变量中有凭据。它返回错误Exception: OSError: [Errno 63] File name too long。我认为发生错误是因为它将凭据作为路径。
我现在找不到连接到谷歌存储收费的方法。
这是我为获得客户所做的超简短版本:
from google.cloud import storage
google_credentials = get_credentials()
client = storage.Client.from_service_account_json(google_credentials)
有什么建议可以在 Azure 功能中使用服务帐户连接到 google 吗?
最好的:-)
【问题讨论】:
-
google_credentials的内容是什么?它的类型是什么? -
您好@guillaumeblaquiere,感谢您的回答。类型是
<class 'google.oauth2.service_account.Credentials'>SInce 今天早上我解决了这个问题并且有另一个想法,我收到了不同的错误消息:``` 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) ```这里的错误信息是DefaultCredentialsError: Could not automatically determine.... -
...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错误消息无济于事,因为我认为我明确提供了凭据 -
您不能在本地和临时将文件存储在 Azure Functions 上,例如
/tmp目录?无论如何,如果您有类似之前评论的路径,只需执行此操作client = storage.Client.from_service_account_json(<CREDENTIAL_PATH>) -
@guillaumeblaquiere 我完全同意你的回答,但我没有路径。这仅用于我的 Jupyter 笔记本中的本地测试。我正在寻找一种解决方案,我可以从我的密钥库中读取 JSON 并登录到谷歌存储
标签: python azure azure-functions google-cloud-storage google-authentication