使用服务帐户从 Python 部署 App Engine 版本



尝试使用服务帐户从 Python 部署 App Engine 实例。目标是启动大量实例,执行一些繁重的网络任务(下载和上传文件(并在事后关闭它们。 我正在尝试使用Python运行时的服务帐户执行此操作,但收到以下错误

TypeError: Missing required parameter "servicesId"

可能有什么问题,或者有更好的解决方案来完成这样的任务?谢谢,代码如下:

SCOPES = ['https://www.googleapis.com/auth/cloud-platform']
SERVICE_ACCOUNT_FILE = 'service.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
gcp = build('appengine', 'v1', credentials=credentials)
res = gcp.apps().create(body={"id":"251499913983"})
app_json = {
"deployment": {
"files": {
"my-resource-file1": {
"sourceUrl": "https://storage.googleapis.com/downloader_sources/hello-world/main.py"
}
}
},
"handlers": [
{
"script": {
"scriptPath": "main.app"
},
"urlRegex": "/.*"
}
],
"runtime": "python27",
"threadsafe": True
}
res2 = gcp.apps().services().versions().create(body=app_json)

我想您需要指定要部署到的服务。您可以使用默认值:

gcp.apps().services().versions().create(serviceID=default, body=app_json)

有关更多详细信息,请参阅文档。

最新更新