通过Terraform代码创建Azure Automation帐户运行时获得不良请求错误

发布于 2025-01-18 08:16:17 字数 1166 浏览 4 评论 0原文

我正在通过Terraform代码创建一本简单的运行书。 Below is the code that I am using:

resource "azurerm_automation_runbook" "example" {
  name                    = "AzureVMslist"
  location                = azurerm_resource_group.example.location
  resource_group_name     = azurerm_resource_group.example.name
  automation_account_name = azurerm_automation_account.example.name
  log_verbose             = "true"
  log_progress            = "true"
  description             = "This is an example runbook"
  runbook_type            = "PowerShell"
  publish_content_link {
    uri = "" #not mentioning my uri
  }
}

terraform plan is successful and when I ran terraform apply then getting below:

azurerm_automation_runbook.example:创建...

错误:创建 /更新runbook :(名称为“ azurevmslist” / automation帐户名称“ automation123” / resource group“ poc_terraform”):automation.runbookclient#creationorupdate:creationorupdate:faility to reverts to request = 400- statuscode = 400-原始错误:outorest-原始错误:自动错误:自动/azure:服务返回错误。 status = 400代码=“ badrequest” message =“ {” message“:”指定的无效参数。参数内容不能为null。”}“

How can we fix this error?

I am creating a simple runbook through the terraform code. Below is the code that I am using:

resource "azurerm_automation_runbook" "example" {
  name                    = "AzureVMslist"
  location                = azurerm_resource_group.example.location
  resource_group_name     = azurerm_resource_group.example.name
  automation_account_name = azurerm_automation_account.example.name
  log_verbose             = "true"
  log_progress            = "true"
  description             = "This is an example runbook"
  runbook_type            = "PowerShell"
  publish_content_link {
    uri = "" #not mentioning my uri
  }
}

terraform plan is successful and when I ran terraform apply then getting below:

azurerm_automation_runbook.example: Creating...

Error: creating/updating Runbook: (Name "AzureVMslist" / Automation Account Name "automation123" / Resource Group "poc_terraform"): automation.RunbookClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="{"Message":"Invalid argument specified. Argument content cannot be null."}"

How can we fix this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乱世争霸 2025-01-25 08:16:17

我发现了这个问题并且已经解决了。该问题是由于我们用于publish_content_link 的虚拟/空uri 造成的。因此,我们需要使用 Valid uri,以便自动创建 Runbook。

我通过获取一个示例 powershell 脚本文件解决了这个问题,并且在代码中使用了该文件。

data "local_file" "example" {
  filename = "${path.module}/AzureVM.ps1"
}

我们使用 content = data.local_file.example.content 而不是在代码中发布内容。

I found the issue and I have fixed it. The issue is because of the dummy/empty uri that we are using for publish_content_link. So we need to use the Valid uri so that the runbook will get create automatically.

I have fixed this issue by taking one sample powershell script file and I have used that file in the code.

data "local_file" "example" {
  filename = "${path.module}/AzureVM.ps1"
}

and we have use the content = data.local_file.example.content instead of publish the content in the code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文