我正在尝试使用本文中的信息:
在部署时将VM装载到Azure自动化并应用配置。
我正在使用Terraform进行部署,以下是我用于扩展的代码:
resource "azurerm_virtual_machine_extension" "cse-dscconfig" {
name = "${var.vm_name}-dscconfig-cse"
location = "${azurerm_resource_group.my_rg.location}"
resource_group_name = "${azurerm_resource_group.my_rg.name}"
virtual_machine_name = "${azurerm_virtual_machine.my_vm.name}"
publisher = "Microsoft.Powershell"
type = "DSC"
type_handler_version = "2.76"
depends_on = ["azurerm_virtual_machine.my_vm"]
settings = <<SETTINGS
{
"configurationArguments": {
"RegistrationUrl": "${var.endpoint}",
"NodeConfigurationName": "VMConfig"
}
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"configurationArguments": {
"registrationKey": {
"userName": "NOT_USED",
"Password": "${var.key}"
}
}
}
PROTECTED_SETTINGS
}
通过执行以下命令并将该值传递到Terraform中,我在执行时获得了RegistrationURL
值:
$endpoint = (Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $tf_state_rg -AutomationAccountName $autoAcctName).Endpoint
通过执行以下命令并将该值传递到Terraform中,我在执行时获得了Password
值:
$key = (Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $tf_state_rg -AutomationAccountName $autoAcctName).PrimaryKey
我可以从VM的日志中得知扩展已安装,但从未向自动化帐户注册。
答案 0 :(得分:1)
找出问题所在。该文档缺少某些方面的详细信息,因此实际上是通过反复试验才发现造成问题的原因。我在NodeConfigurationName
属性中输入了错误的值。文档关于此属性的说明:Specifies the node configuration in the Automation account to assign to the node.
没有使用DSC的丰富经验,我打断它的意思是该配置的名称,如刀片服务器Configurations
的{{1}}部分中所见。 Azure门户中的自动化帐户。
State configuration (DSC)
属性的真正含义是配置中的NodeConfigurationName
定义,它的格式应为ConfigurationName.NodeName。例如,我的配置名称为Node
,在配置源中,我定义了一个VMConfig
块,称为Node
。因此,使用此... localhost
属性的值应为NodeConfigurationName
。