简体   繁体   English

AzureRM 自动化 DSC 配置

[英]AzureRM Automation DSC Configuration

I'm trying to configure Azure DSC Configuration, but I am running into two issues.我正在尝试配置 Azure DSC 配置,但我遇到了两个问题。

  1. I continue to get this error message我继续收到此错误消息
  • Error = 'invalid character 'c' looking for beginning of value' JSON = 'configuration cdavdtest {}'* *2.错误 = '无效字符 'c' 寻找值的开头' JSON = '配置 cdavdtest {}'* *2。 No matter what I do to the resource azurerm_automation_dsc_configuration, it throws this command which is a reference to my last terraform plan / apply that failed.无论我对资源 azurerm_automation_dsc_configuration 做什么,它都会抛出此命令,该命令引用了我上次失败的 terraform 计划/应用。 Changing the configuration does nothing, and the old error continues.更改配置没有任何作用,旧错误继续存在。 I appreciate any help.我感谢任何帮助。 See the cdavdtest in bold compared to the resource also in bold below.与下面也以粗体显示的资源相比,请参阅粗体显示的 cdavdtest。 Also the name doesn't update it still says dsc_config even though I updated it to dsc_configa.名称也没有更新,即使我将其更新为 dsc_configa,它仍然显示 dsc_config。

Error: making Read request on AzureRM Automation Dsc Configuration content "cdavdtest": automation.DscConfigurationClient#GetContent: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'invalid character 'c' looking for beginning of value' JSON = 'configuration cdavdtest {}' │ │ with azurerm_automation_dsc_configuration.dsc_config, │ on automationaccount.tf line 17, in resource "azurerm_automation_dsc_configuration" "dsc_config": │ 17: resource azurerm_automation_dsc_configuration dsc_config {错误:对 AzureRM Automation Dsc 配置内容“cdavdtest”发出读取请求:automation.DscConfigurationClient#GetContent:响应请求失败:StatusCode = 200 - 原始错误:解组时发生错误 JSON - 错误 = '无效字符 'c' 寻找开始价值'JSON ='配置cdavdtest {}'││与azurerm_automation_dsc_configuration.dsc_config,│在automationaccount.tf第17行,在资源“azurerm_automation_dsc_configuration”“dsc_config”中:│17:资源azurerm_automation_dsc_configuration {

resource azurerm_automation_account automation_account {
    name = "${var.avd.name}-automationaccount"
    location = azurerm_resource_group.rg.location
    resource_group_name = azurerm_resource_group.rg.name
    sku_name = "Basic"
}

output "end_point" {
    value = azurerm_automation_account.automation_account.dsc_server_endpoint
}

output registration_key {
    value = azurerm_automation_account.automation_account.dsc_primary_access_key
}


resource azurerm_automation_dsc_configuration dsc_configa {
    name = "**test**"
    location = azurerm_resource_group.rg.location
    resource_group_name = azurerm_resource_group.rg.name 
    automation_account_name = azurerm_automation_account.automation_account.name
    description = "Configuration node for Azure Virtual Desktop"
    content_embedded = "Configuration **test** {}"
    log_verbose = true
}


I have tried commenting out the code and I still get the error.我已经尝试注释掉代码,但仍然出现错误。 I've tried updating the name.我试过更新名称。 I've tried using the <<BODY and writing out the configuration but this still persists.我试过使用 <<BODY 并写出配置,但这仍然存在。

Tested in my Environment was getting the same error.在我的环境中测试得到同样的错误。 The error is due to azurerm_automation_dsc_configuration is broken since provider version 2.96.0该错误是由于azurerm_automation_dsc_configuration 自提供程序版本 2.96.0 以来已损坏

I was using the lasted terraform provider version ie 3.0.1我使用的是最新的 terraform 提供商版本,即3.0.1

在此处输入图像描述

在此处输入图像描述

Solution : Would Suggest you to please use the provider version between version = ">=2.10,<=2.30"解决方案:建议您使用version = ">=2.10,<=2.30"之间的提供程序版本

Terraform Code Terraform 代码

main.tf file main.tf文件

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">=2.10,<=2.30"
    }
  }
}

provider "azurerm" {
  features{}
  
}


data "azurerm_resource_group" "example" {
  name     = "XXXXXXxXXX"
}

resource "azurerm_automation_account" "example" {
  name                = "account1"
  location            = data.azurerm_resource_group.example.location
  resource_group_name = data.azurerm_resource_group.example.name
  sku_name = "Basic"
}


output "end_point" {
    value = azurerm_automation_account.example.dsc_server_endpoint
}

output "registration_key" {
    value = azurerm_automation_account.example.dsc_primary_access_key
}

resource "azurerm_automation_dsc_configuration" "example" {
  name                    = "test"
  resource_group_name     = data.azurerm_resource_group.example.name
  automation_account_name = azurerm_automation_account.example.name
  location                = data.azurerm_resource_group.example.location
  content_embedded        = "configuration test {}"
  log_verbose = true

  
}

OutPut--输出 -

在此处输入图像描述


在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM