首页 > 解决方案 > AADLoginForWindows 的 Terraform Azure VM 扩展类型和 type_handler_version 参数值

问题描述

我正在尝试使用 terraform azurerm 提供程序的 1.21.0 版将 AADLoginForWindows VM 扩展添加到 Azure Windows Server VM。

安装失败并显示以下消息:

Failure sending request: StatusCode=404 -- Original Error: Code="ArtifactNotFound" Message="Extension with publisher 'Microsoft.Azure.ActiveDirectory', type 'AADLoginForWindows', and type handler version '1.0' could not be found in the extension repository.

应用 AADLoginForLinux 的 Terraform 配置(有效):

resource "azurerm_virtual_machine_extension" "AADLoginForLinux" {
    name                              = "AADLoginForLinux"
    location                          = "${azurerm_virtual_machine.vm-linux-bastion.location}"
    resource_group_name               = "${azurerm_virtual_machine.vm-linux-bastion.resource_group_name}"
    virtual_machine_name              = "${azurerm_virtual_machine.vm-linux-bastion.name}"
    publisher                         = "Microsoft.Azure.ActiveDirectory.LinuxSSH"
    type                              = "AADLoginForLinux"
    type_handler_version              = "1.0"
    auto_upgrade_minor_version        = true
}

我怀疑 type 或 type_handler_version 参数值有问题,但我不明白这些值与什么有关(有些谷歌搜索没有提供启示)。

AADLoginForWindows 没有可用的文档(也许这应该是一个警告!;))但我希望它的工作方式与 AADLoginForLinux 大致相同,它允许我们使用直接在 Azure AD 中管理的凭据登录 Linux VM。

我的 Terraform 配置是:

resource "azurerm_virtual_machine_extension" "AADLoginForWindows" {
    name                              = "AADLoginForWindows"
    location                          = "${azurerm_resource_group.rg-dataaq-prd-neu-ftps.location}"
    resource_group_name               = "${azurerm_resource_group.rg-dataaq-prd-neu-ftps.name}"
    virtual_machine_name              = "${azurerm_virtual_machine.vm-windows.name}"
    publisher                         = "Microsoft.Azure.ActiveDirectory"
    type                              = "AADLoginForWindows"
    type_handler_version              = "1.0"
    auto_upgrade_minor_version        = true
    depends_on                     = ["azurerm_virtual_machine_extension.antimal"]
}

使用az cli我可以找到有关扩展版本的以下信息:

az vm extension image list --name AADLoginForWindows
[
  {
    "name": "AADLoginForWindows",
    "publisher": "Microsoft.Azure.ActiveDirectory",
    "version": "0.3.0.0"
  },
  {
    "name": "AADLoginForWindows",
    "publisher": "Microsoft.Azure.ActiveDirectory",
    "version": "0.3.1.0"
  }
]

查询扩展的特定版本:

az vm extension image show --name AADLoginForWindows --publisher "Microsoft.Azure.ActiveDirectory" --location northeurope --version "0.3.1.0"
{
  "computeRole": "IaaS",
  "handlerSchema": null,
  "id": "/Subscriptions/.../Providers/Microsoft.Compute/Locations/northeurope/Publishers/Microsoft.Azure.ActiveDirectory/ArtifactTypes/VMExtension/Types/AADLoginForWindows/Versions/0.3.1.0",
  "location": "northeurope",
  "name": "0.3.1.0",
  "operatingSystem": "Windows",
  "supportsMultipleExtensions": false,
  "tags": null,
  "type": null,
  "vmScaleSetEnabled": false
}

我认为“发布者” Terraform 参数必须等于第一个查询中的发布者值。

type 在第二个查询中返回为 null 的事实让我想知道这是否真的映射到“type”Terraform 参数。

似乎没有任何与 type_handler_version 相关的内容。

有谁知道我应该使用什么配置来安装这个 VM 扩展?

谁能更详细地描述 Terraform 类型和 type_handler_version 参数(并描述如何找到有效值)?

为了测试这是否是 Terraform 错误,我尝试使用该az cli工具应用扩展:

az vm extension set -n AADLoginForWindows --publisher "Microsoft.Azure.ActiveDirectory" --vm vmname --resource-group rg-name

这给出了以下错误:

Handler 'Microsoft.Azure.ActiveDirectory.AADLoginForWindows' has reported failure for VM Extension 'AADLoginForWindows' with terminal error code '1007' and error message: 'Install failed for plugin (name: Microsoft.Azure.ActiveDirectory.AADLoginForWindows, version 0.3.1.0) with exception Command C:\Packages\Plugins\Microsoft.Azure.ActiveDirectory.AADLoginForWindows\0.3.1.0\AADLoginForWindowsHandler.exe of Microsoft.Azure.ActiveDirectory.AADLoginForWindows has exited with Exit code: 51'

标签: azureterraform

解决方案


更改您的 type_handler_version 以匹配实际版本(根据您的发现为 0.3.1.0)

type_handler_version              = "0.3.1.0"

它不能降级版本,只能升级,只能是次要版本。

Linux 版本有效,因为(所以它高于 1.0.0.0):
在此处输入图像描述

虽然 windows 版本仍然不在 1.0 上:
在此处输入图像描述


推荐阅读