【问题标题】:azure failed to add extension to virtual machine天蓝色无法将扩展添加到虚拟机
【发布时间】:2014-12-27 13:40:25
【问题描述】:

我正在尝试将反恶意软件扩展添加到虚拟机以进行保护,但是当我尝试在 Azure 门户中添加扩展时,我收到以下错误:

无法将扩展添加到虚拟机。虚拟机请求无效 指定的源镜像是用户镜像。图片必须是平台图片。

我已经安装了 VMAgent。

作为额外信息,我尝试使用 powershell 命令安装扩展,方法是使用以下命令并获得相应的响应:

$vm = Get-AzureVM –ServiceName "MyServiceName" –Name "MyVMName"

详细:... - 完成操作:获取部署*

Set-AzureVMExtension -Publisher Microsoft.Azure.Security -ExtensionName IaaSAntimalware -Version 1.* -VM $vm.VM

警告:资源扩展引用列表为空或为空

可用性集名称: 配置集:{Microsoft.WindowsAzure.Commands.ServiceManagement.Model.NetworkConfigurationSet} DataVirtualHardDisks:{“MyVMName”} 标签 : OSVirtualHardDisk:Microsoft.WindowsAzure.Commands.ServiceManagement.Model.OSVirtualHardDisk 角色名称:“我的虚拟机名称” 角色大小:大 角色类型:PersistentVMRole WinRM证书: X509证书: NoExportPrivateKey:假 NoRDPEndpoint:错误 无SSH端点:假 DefaultWinRmCertificateThumbprint:F4CF28C735C5E557C7B47742E4F16A08959272F1 ProvisionGuestAgent: ResourceExtensionReferences : {IaaSAntimalware} DataVirtualHardDisksToBeDeleted :

更新-AzureVM -Name "MyServiceName" -ServiceName "MyVMName" -VM $vm.VM

详细:11:15:10 - 完成操作:获取部署 详细:11:15:10 - 开始操作:更新 AzureVM 详细:11:15:42 - 完成操作:Update-AzureVM

OperationDescription OperationId OperationStatus -------- ----------- --------------- 更新-AzureVM 387b77a2-c8fc-233a-913d-cd364c855429 成功

运行命令后,我检查并在 VM 上安装了 VMAgent,但没有扩展。

有人有什么想法吗?

谢谢!!

【问题讨论】:

    标签: azure virtual


    【解决方案1】:

    原因可能是您的第一行 $vm = Get-AzureVM –ServiceName "MyServiceName" –Name "MyVMName"

    • 未指定 -servicename 和 -name 时,Get-AzureVM 不返回任何 VM 对象
    • Set-AzureVMextension 仅适用于 -VM 输入

    试试这个:

    https://gist.github.com/andreaswasita/428fc5519b0ddac76b01

    【讨论】:

      【解决方案2】:

      根据我的经验,此警告是由于 Azure 来宾代理未部署在 VM 上、未在 VM 上运行或已过期。如果 VM 没有健康(且当前)的来宾代理,您将无法部署扩展。

      您可以通过以下方式检查访客代理状态:

      $vm.GuestAgentStatus
      

      您会寻找“就绪”的“状态”;其他任何事情,扩展都可能会失败。然后扩展 Klaad 的代码...

      # Azure Cloud Service and Azure VM Name 
      $service= Read-Host -Prompt 'Azure Cloud Service:' 
      $name = Read-Host -Prompt 'Azure VM:' 
      
      # Get the Cloud Service and Azure VM 
      $vm = Get-AzureVM –ServiceName $service –Name $name 
      
      # Check for health of the agent
      If ($vm.GuestAgentStatus.Status -ne "Ready") {
          Write-Error "The VM agent appears to not be installed or is in an unhealthy state."
      }
      Else {
          # Add Microsoft Antimalware Agent to the Azure VM 
          Set-AzureVMExtension -Publisher Microsoft.Azure.Security -ExtensionName IaaSAntimalware -Version 1.* -VM $vm.VM 
      
           # Update the Azure VM and install the Antimalware Agent 
          Update-AzureVM -Name $name -ServiceName $service -VM $vm.VM 
      }
      

      要检查代理是否存在,可以在服务器上查找以下三个进程:

      WaAppAgent.exe
      WindowsAzureGuestAgent.exe
      WindowsAzureTelemetryService.exe
      

      您可以从here 下载代理(编辑时的当前版本为 2.6.1198.718)。

      安装需要两步(来源:Zach Millis):

      1. 安装代理。这需要您以管理员身份运行 PowerShell 并在 PowerShell 提示符下执行安装程序。 (不要直接运行)
      2. 更新 Azure,使其了解代理。这需要执行以下代码:

      代码:

      # Azure Cloud Service and Azure VM Name
      $service= Read-Host -Prompt 'Azure Cloud Service:' 
      $name = Read-Host -Prompt 'Azure VM:' 
      
      # Get the Cloud Service and Azure VM 
      $vm = Get-AzureVM –ServiceName $service –Name $name 
      
      # Provision the guest agent so Azure knows about it
      $vm.VM.ProvisionGuestAgent = $TRUE
      
      # Update the Azure VM and install the Antimalware Agent 
      $vm | Update-AzureVM
      
      # Refresh the connection to the VM to get the new status
      $vm = Get-AzureVM –ServiceName $service –Name $name 
      
      # Check status - should now be "Ready"
      $vm.GuestAgentStatus
      

      应该是这样的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-10
        • 1970-01-01
        • 2014-03-30
        • 1970-01-01
        • 2017-05-14
        • 1970-01-01
        相关资源
        最近更新 更多