【发布时间】:2021-03-03 17:58:16
【问题描述】:
我正在尝试使用如下自定义脚本扩展部署到我的虚拟机规模集。
az vmss extension set --debug --name 'CustomScriptExtension' `
--resource-group 'my-rg' `
--publisher 'Microsoft.Compute' `
--version '1.9.5' `
--vmss-name 'myvmss' `
--settings '{\"commandToExecute\": \"powershell.exe ./download-package.ps1\", \"fileUris\": [\"https://[REDACTED].blob.core.windows.net/upload/download-package.ps1\"]}' `
--protected-settings '{\"managedIdentity\": {\"objectId\": \"[REDACTED]\"}}'
运行时出现以下错误:
cli.azure.cli.core.azclierror:部署失败。相关 ID:73f4d16b-afe0-4373-8773-1d7dd7d26940。 VM 在处理扩展“CustomScriptExtension”时报告失败。错误消息:“无法下载所有指定的文件。正在退出。错误消息:引发了 'Microsoft.WindowsAzure.GuestAgent.Plugins.CustomScriptHandler.Downloader.MsiNotFoundException' 类型的异常。”
有关故障排除的更多信息,请访问https://aka.ms/VMExtensionCSEWindowsTroubleshoot 部署失败。相关 ID:73f4d16b-afe0-4373-8773-1d7dd7d26940。 VM 在处理扩展“CustomScriptExtension”时报告失败。错误消息:“无法下载所有指定的文件。正在退出。错误消息:引发了 'Microsoft.WindowsAzure.GuestAgent.Plugins.CustomScriptHandler.Downloader.MsiNotFoundException' 类型的异常。”
要下载的文件需要身份验证,因此我为规模集分配了系统分配的身份,并在托管 powershell 文件的存储帐户上授予它Storage Blob Data Reader 角色。
VM 上的自定义扩展日志提示无法获取 vm 的身份:
[7108+00000001] [11/20/2020 09:12:28.79] [INFO] Handler successfully enabled
[7108+00000001] [11/20/2020 09:12:28.80] [INFO] Loading configuration for sequence number 1
[7108+00000001] [11/20/2020 09:12:28.84] [INFO] HandlerSettings = ProtectedSettingsCertThumbprint: [REDACTED], ProtectedSettings: {[REDACTED]}, PublicSettings: {FileUris: [https://[REDACTED].blob.core.windows.net/upload/download-package.ps1], CommandToExecute: powershell.exe ./download-package.ps1}
[7108+00000001] [11/20/2020 09:12:29.26] [INFO] Downloading files specified in configuration...
[7108+00000001] [11/20/2020 09:12:30.90] [INFO] Attempting to get MSI from IMDS
[7108+00000001] [11/20/2020 09:12:31.04] [WARN] WebClient: non retryable error occurred System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at Microsoft.WindowsAzure.GuestAgent.Plugins.MsiUtils.WebClient.<>c__DisplayClass3_0.<DownloadStringWithRetries>b__0()
at Microsoft.WindowsAzure.GuestAgent.Plugins.MsiUtils.WebClientWithRetryAbstract.ActionWithRetries(Action action)
[7108+00000001] [11/20/2020 09:12:31.14] [ERROR] Unknown exception occurred while attempting to get MSI token System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at Microsoft.WindowsAzure.GuestAgent.Plugins.MsiUtils.WebClient.<>c__DisplayClass3_0.<DownloadStringWithRetries>b__0()
at Microsoft.WindowsAzure.GuestAgent.Plugins.MsiUtils.WebClientWithRetryAbstract.ActionWithRetries(Action action)
at Microsoft.WindowsAzure.GuestAgent.Plugins.MsiUtils.WebClient.DownloadStringWithRetries(Uri address)
at Microsoft.WindowsAzure.GuestAgent.Plugins.MsiUtils.MsiProvider.GetMsiHelper(NameValueCollection queries)
[7108+00000001] [11/20/2020 09:12:31.14] [INFO] Msi was not obtained
我可以通过Invoke-WebRequest -Method Get -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/' 从元数据端点检索身份令牌,这样看起来设置正确。
任何关于问题可能是什么或如何进一步诊断此问题的建议将不胜感激。
【问题讨论】:
-
我有完全相同的问题,但使用的是 UserAssigned Managed Identities。看来 thia 完全被破坏了,正如这个 github 问题中所记录的那样:github.com/Azure/custom-script-extension-linux/issues/165 在被报告后一年多没有得到修复。
标签: azure azure-virtual-machine azure-vm-scale-set