使用Terraform导入Azure Automation Runbook

时间:2018-08-09 08:52:01

标签: azure terraform terraform-provider-azure azure-runbook

任何人都可以帮助我一个问题:我想使用Terraform从Runbook画廊中导入Azure自动帐户中的Runbook。在下面的示例中,我引用的是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}"
  }
  }`

1 个答案:

答案 0 :(得分:0)

在门户网站中

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

enter image description here

复制网址

enter image description here

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

对于上面的图片(例如,天蓝色runbook的hello世界),它以

重定向到我的URI

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

只需尝试将其粘贴到您的代码(<?php function convertCountry( $countrySlug ) { $countries = "Andorra: AR|United-Arab-Emirates: UAE|Afghanistan: AFG|Antigua-And-Barbuda: AAB|Anguilla: ANG|Albania: ALB|Armenia: ARM"; $countryArray = explode('|', $countries); return array_search($countrySlug, $countryArray); } echo convertCountry('United-Arab-Emirates'); ?>

uri = "${var.runbooklink}"

注意,源代码中的运行手册的名称应为您的运行手册的名称