Azure 自定义扩展 Blob 返回 403 Forbidden

标签 azure storage azure-rm-template azureportal azure-vm-scale-set

我尝试运行自定义脚本以静默方式将软件安装到我的 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 "
  1. 尝试将 fileUris 移至设置部分,出现同样的错误。
  2. 不同类型Handler版本1.19、1.10、1.17。
  3. 尝试添加 {objectID:} ScaleSet 身份 ID 仅当删除托管标识并添加 StoraceAccountName: StorageAccountKey: 时才有效 我缺少什么?

谢谢!

最佳答案

如果有人遇到同样的问题,我找到了解决方案。

  1. 确保在设置部分添加fileUris和时间戳,时间戳类似于脚本的版本控制,每次传递更大的整数时都会创建一个新版本并触发脚本,您可以检查 Windows VM C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.10.2\Status 的输出
  2. 确保将存储 Blob 数据读取器角色分配添加到规模集身份

关于Azure 自定义扩展 Blob 返回 403 Forbidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73249030/

相关文章:

python - 当我在 Pulumi 中使用 F-string 通过 Python 创建连接字符串时收到错误

azure - 为什么 Azure Web 应用程序的入站 IP 对端点返回 404,但使用 url 工作正常?

multithreading - 为什么使用线程局部存储(TlsAlloc、TlsGetValue、ets)而不是局部变量

azure - ARM 模板错误 在请求中发现错误的 JSON 内容

azure - 使用arm模板在Azure数据工厂中启用诊断

asp.net - 从源代码管理进行 Azure 网站部署期间的 Web.config 转换

azure - 异步 HttpClient 调用不会自动在应用服务的 Azure 应用见解中显示为依赖项

windows - 驱动程序级别的 USB 磁盘加密

能否用C知道运行时是否对磁盘进行了文件操作?

azure - 通过 ARM 模板将节点池添加到现有 AKS 集群