在 Linux 上使用 Azure CLI 上传 WebJob 失败(进程内存不足)
Upload of WebJob fails with Azure CLI on Linux (process out of memory)
我们正尝试在 linux 上使用 Azure CLI 上传 WebJob 作为我们持续部署管道的一部分。
azure site job upload -v $WEB_JOB_NAME $WEB_JOB_TYPE run.zip $WEB_SITE_NAME
但是在 "Uploading WebJob" 步骤等待 > 20 分钟后命令失败。
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory
更多信息:
- cli 已正确验证。我们可以很好地触发已经存在的 WebJobs。
- 完全相同的 run.zip 从 Windows 上的 Microsoft Azure Powershell 成功上传。
- zip 文件包含一个可运行的 jar 和一个用于启动它的小 .cmd 脚本。文件大小:30 MB
- 我们尝试设置 verbose-flag,但它没有提供更多信息。
这看起来像是 xplat-cli 中的错误。我不认为它与 linux 相关,因为当我 运行 在 Windows 上使用 xplat-cli 时我也遇到了同样的错误,并且 zip 文件也大约为 30 MB。我建议在这里为他们开一个问题 https://github.com/Azure/azure-xplat-cli/issues
解决方法:
您可以使用 cli 获取站点信用,然后使用 curl
上传网络作业。这是一个可以做到这一点的小脚本。
# get site config from azure cli
siteConfig=`azure site show $WEB_SITE_NAME -d --json`
# extract publishing username and password for the site
publishingUserName=`echo $siteConfig| python -c "import json,sys;obj=json.load(sys.stdin);print obj['config']['publishingUserName'];"`
publishingPassword=`echo $siteConfig| python -c "import json,sys;obj=json.load(sys.stdin);print obj['config']['publishingPassword'];"`
siteScmUrl=`echo $siteConfig | python -c "import json,sys;obj=json.load(sys.stdin);print obj['site']['siteProperties']['properties']['RepositoryUri'];"`
# build the path for the webjob on the server
jobPath="zip/site/wwwroot/App_Data/jobs/$WEB_JOB_TYPE/$WEB_JOB_NAME"
fullUrl=$siteScmUrl$jobPath
# Upload the zip file using curl
curl -XPUT --data-binary @run.zip -u $publishingUserName:$publishingPassword $fullUrl
您可以在此处阅读有关 webjob REST API 的更多信息https://github.com/projectkudu/kudu/wiki/WebJobs-API
我们正尝试在 linux 上使用 Azure CLI 上传 WebJob 作为我们持续部署管道的一部分。
azure site job upload -v $WEB_JOB_NAME $WEB_JOB_TYPE run.zip $WEB_SITE_NAME
但是在 "Uploading WebJob" 步骤等待 > 20 分钟后命令失败。
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory
更多信息:
- cli 已正确验证。我们可以很好地触发已经存在的 WebJobs。
- 完全相同的 run.zip 从 Windows 上的 Microsoft Azure Powershell 成功上传。
- zip 文件包含一个可运行的 jar 和一个用于启动它的小 .cmd 脚本。文件大小:30 MB
- 我们尝试设置 verbose-flag,但它没有提供更多信息。
这看起来像是 xplat-cli 中的错误。我不认为它与 linux 相关,因为当我 运行 在 Windows 上使用 xplat-cli 时我也遇到了同样的错误,并且 zip 文件也大约为 30 MB。我建议在这里为他们开一个问题 https://github.com/Azure/azure-xplat-cli/issues
解决方法:
您可以使用 cli 获取站点信用,然后使用 curl
上传网络作业。这是一个可以做到这一点的小脚本。
# get site config from azure cli
siteConfig=`azure site show $WEB_SITE_NAME -d --json`
# extract publishing username and password for the site
publishingUserName=`echo $siteConfig| python -c "import json,sys;obj=json.load(sys.stdin);print obj['config']['publishingUserName'];"`
publishingPassword=`echo $siteConfig| python -c "import json,sys;obj=json.load(sys.stdin);print obj['config']['publishingPassword'];"`
siteScmUrl=`echo $siteConfig | python -c "import json,sys;obj=json.load(sys.stdin);print obj['site']['siteProperties']['properties']['RepositoryUri'];"`
# build the path for the webjob on the server
jobPath="zip/site/wwwroot/App_Data/jobs/$WEB_JOB_TYPE/$WEB_JOB_NAME"
fullUrl=$siteScmUrl$jobPath
# Upload the zip file using curl
curl -XPUT --data-binary @run.zip -u $publishingUserName:$publishingPassword $fullUrl
您可以在此处阅读有关 webjob REST API 的更多信息https://github.com/projectkudu/kudu/wiki/WebJobs-API