1

任何人都可以帮我问一下:我想使用 Terraform 从运行手册库中导入 azure 自动化帐户中的运行手册。在下面的示例中,我指的是 URI,但我想从 Runbook 库导入:

  resource "azurerm_automation_runbook" "example" {
  name                = "Get-AzureVMTutorial"
  location            = "${azurerm_resource_group.example.location}"
  resource_group_name = "${azurerm_resource_group.example.name}"
  account_name        = "${azurerm_automation_account.example.name}"
  log_verbose         = "true"
  log_progress        = "true"
  description         = "This is an example runbook"
  runbook_type        = "PowerShellWorkflow"
  publish_content_link {
  uri = "${var.runbooklink}"
  }
  }`
4

1 回答 1

0

在门户中

自动化帐户 -> Runbooks -> 浏览库 -> 选择要导入的 Runbooks -> 查看源项目

在此处输入图像描述

复制网址

在此处输入图像描述

查看源代码项目将重定向到该特定 Runbook 的 URI(gallery.technet.microsoft.com中的源代码)

对于上面的图像(例如 hello world for azure runbook ),它会将 URI 重定向到我

https://gallery.technet.microsoft.com/scriptcenter/The-Hello-World-of-Windows-81b69574/file/111354/1/Write-HelloWorld.ps1

只需尝试将其粘贴到您的代码中(uri = "${var.runbooklink}"

resource "azurerm_automation_runbook" "demorunbook" {
  name                = "Write-HelloWorld"
  location            = "${azurerm_resource_group.development1.location}"
  resource_group_name = "${azurerm_resource_group.development1.name}"
  account_name        = "automationAccount1"
  log_verbose         = "true"
  log_progress        = "true"
  description         = "This is an example runbook"
  runbook_type        = "PowerShellWorkflow"
  publish_content_link {
  uri = "https://gallery.technet.microsoft.com/scriptcenter/The-Hello-World-of-Windows-81b69574/file/111354/1/Write-HelloWorld.ps1"
  }
  }

注意源代码中的 Runbook 名称应为 Runbook 名称的名称

于 2018-08-09T11:19:49.120 回答