azure - Terraform:如何将 PS 模块从库安装到 Azure 自动化中?

标签 azure terraform terraform-provider-azure azure-automation

如何使用 Terraform 将 PowerShel 模块从库安装到我的 azure 自动化帐户中?

我尝试使用 powershellgallery API url:

resource "azurerm_automation_account" "aac" {
  name                = var.azure_automation_account_name
  location            = var.location
  tags                = var.tags
  resource_group_name = var.resource_group
  sku_name = "Basic"
}

resource "azurerm_automation_module" "az_accounts" {
  name                    = "az_accounts"
  resource_group_name     = var.resource_group
  automation_account_name = azurerm_automation_account.aac.name

  module_link {
    uri = "https://www.powershellgallery.com/api/v2/package/az.accounts/2.2.4"
  }
}

这总是给我一个错误(我尝试了几个不同版本的模块,没有区别):

Error: Error waiting for Module "az_accounts" (Automation Account "XXX" / Resource Group "YYY") to finish provisioning: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: Cannot import the module of name az_accounts, as the module structure was invalid.

我在这里做错了什么?

一月

最佳答案

模块名称应为“Az.Accounts”。这对我有用。

resource "azurerm_automation_module" "example" {
  name                    = "Az.Accounts"
  resource_group_name     = azurerm_resource_group.example.name
  automation_account_name = azurerm_automation_account.example.name

  module_link {
    uri = "https://www.powershellgallery.com/api/v2/package/az.accounts/2.2.4"
  }
}

enter image description here

关于azure - Terraform:如何将 PS 模块从库安装到 Azure 自动化中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66041169/

相关文章:

azure - 如何将 Windows Azure VM 移动到不同的关联组?

azure - AKS 中的节点池未缩减至 0 个节点?

amazon-web-services - 如何在 terraform 资源中的 zipmap 和列表上创建嵌套 for 循环

Terraform - AzureDataLake 创建错误响应请求 : StatusCode=403 失败

azure - 使用 cloudinit 创建 Terraform azurerm 虚拟机

azure - 从 Terraform 在 Azure 存储帐户中设置 CORS

c# - Azure webJob 中使用 ILogger 进行 DI

angular - 尝试在azure应用程序中更新nodejs版本时出现问题。无法在azure中执行应用程序的构建

linux - 使用 ASR 模式将 Redhat VM 迁移到 Azure

mysql - 无法使用 terraform 使用 AWSAuthenticationPlugin 创建 mysql 用户