我尝试运行自定义脚本以静默方式将软件安装到我的 Windows Scaleset 这是我的配置 Arm 模板添加到 virtualMachineProfile 就像子资源添加到 ExtensionProfile 这里是代码
{
"name": "InstallSomeCoolStuffs",
"properties":{
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.10",
"autoUpgradeMinorVersion": true,
"settings": {},
"protectedSettings": {
"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File myscript.ps1",
"managedIdentity": {},
"fileUris": ["https://someblob.blob.core.windows.net/src/myscript.ps1"
]
}
}
},
问题是当我尝试使用启用的托管身份部署 ARM 模板并将贡献者角色添加到存储帐户时失败,并显示消息:
"message": "VM has reported a failure when processing extension 'MyScript'. Error message: \"Failed to download all specified files. Exiting. Error Message: The remote server returned an error: (403) Forbidden.\"\r\n\r\nMore information on troubleshooting is available at https://aka.ms/VMExtensionCSEWindowsTroubleshoot "
- 尝试将 fileUris 移至设置部分,出现同样的错误。
- 不同类型Handler版本1.19、1.10、1.17。
- 尝试添加 {objectID:} ScaleSet 身份 ID 仅当删除托管标识并添加 StoraceAccountName: StorageAccountKey: 时才有效 我缺少什么?
谢谢!
最佳答案
如果有人遇到同样的问题,我找到了解决方案。
- 确保在设置部分添加fileUris和时间戳,时间戳类似于脚本的版本控制,每次传递更大的整数时都会创建一个新版本并触发脚本,您可以检查 Windows VM C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.10.2\Status 的输出
- 确保将存储 Blob 数据读取器角色分配添加到规模集身份
关于Azure 自定义扩展 Blob 返回 403 Forbidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73249030/