azure - 在 Azure Pipelines 上将 Packer 作为构建不可变映像任务的一部分运行会返回 ResourceNotFound 错误
问题描述
在 Azure Pipelines 上将 Packer 作为构建不可变映像任务的一部分运行会返回 ResourceNotFound 错误。
这是日志:
[command]d:\a\_temp\1560443280032\packer\packer.exe --version
1.2.4
.. OMISSIS ..
Running packer fix command
[command]d:\a\_temp\1560443280032\packer\packer.exe fix -validate=false d:\a\_temp\1560443280032\default.managed.windows.template-builderUpdated.json
{
.. OMISSIS ..
}
Running packer validate command to ensure template is valid
[command]d:\a\_temp\1560443280032\packer\packer.exe validate -var-file=d:\a\_temp\1rmtqjuiul6pfzkv7busvvaemi.json -var-file=d:\a\_temp\uhd7du4kq3yqnb8ow5d4jwcdi.json d:\a\_temp\1560443280032\default.managed.windows.template-builderUpdated-fixed.json
Template validated successfully.
Running packer build command. Waiting for it to finish...
[command]d:\a\_temp\1560443280032\packer\packer.exe build -force -color=false -var-file=d:\a\_temp\4ehhcm7h7b87enzmq6zz7iudi.json -var-file=d:\a\_temp\su5hmxk6n2ly2vs00pundygb9.json d:\a\_temp\1560443280032\default.managed.windows.template-builderUpdated-fixed.json
==> azure-arm: Running builder ...
azure-arm: Creating Azure Resource Manager (ARM) client ...
==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/COMPUTERNAME' under resource group 'RESOURCEGROUP' was not found.
==> azure-arm:
==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
Build 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
==> Some builds didn't complete successfully and had errors:
--> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
==> Builds finished but no artifacts were created.
##[error]Error: d:\a\_temp\1560443280032\packer\packer.exe failed with return code: 1
执行很早就停止了,实际上只需要 20 秒即可到达错误(工作任务大约需要 30 分钟)。
解决方案
事实证明,在配置 Build Immutable Image 任务时创建的服务主体仅在任务配置期间选择的特定资源组(持有任务使用的存储帐户的资源组)中配置为参与者。
在订阅级别向服务主体名称授予贡献者角色可解决此问题。
运行任务,我们可能会发现这是因为在执行过程中,创建了一个新的临时资源组,因此服务主体需要对整个订阅的贡献者权限(或其中的某个子集)。
这是一个有趣的选择,因为该资源组在任务结束时被删除。
推荐阅读
- css - 如何用纯css凹出一条直线
- python - 安装 allennlp==0.3.0 时应该使用哪个版本的 sanic-cors、sanic 和 sanic-plugins-framework?
- python-3.x - 无法与 KNeighborsClassifier 并行化
- javascript - 放大画布中的点
- kivy - 使用 Kivy 实现 VRAM
- r - 继承错误(x,“日期”):缺少参数“x”,没有默认的 Rstudio
- assembly - 使用 MASM 汇编程序将华氏温度转换为摄氏温度
- c - 修改并返回指向结构的指针
- python - 指定组名时 re.sub() 行为怪异
- node.js - Nginx 配置:一个 nodeJS 应用程序的两个域名