【问题标题】:How to connect azure function with google storage如何将 Azure 功能与谷歌存储连接
【发布时间】: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


【解决方案1】:

最后我看到我正在使用的代码需要一个路径作为参数。我提供了凭据。

【讨论】:

    猜你喜欢
    • 2021-10-18
    • 2021-08-20
    • 2018-12-01
    • 2021-01-25
    • 1970-01-01
    • 2020-05-18
    • 2019-05-12
    • 2022-12-17
    • 2019-05-29
    相关资源
    最近更新 更多