如何使用 Terraform 资源提供程序创建 Azure 机器学习资源?

How to create azure machine learning resource using terraform resource providers?

我想使用 terraform 创建 azure 机器学习工作区 scripts.Is 有任何 terraform 提供程序可以实现此目的。

检查这个 - https://www.terraform.io/docs/providers/azurerm/r/cognitive_account.html

但我认为那里没有直接模块,您可以查看官方 terraform 文档 - https://www.terraform.io/docs/providers/azurerm/

据我所知,Terraform 不在 Azure 提供商中提供 API 来创建 Azure 机器学习。

所以根据我的经验,你只能借助 Terraform 脚本中的 Azure Template and Azure Tool such as Azure CLI 来达到你的目的。

如果您使用 Azure 模板,则可以使用模型 azurerm_template_deployment 执行您的模板来创建 ML。

如果您想使用 Azure CLI,那么您可以使用模型 null_resource 在本地执行您的 CLI 命令。您可以按照步骤 here 进行操作。这也是 Terraform 的示例:

resource "null_resource" "cluster" {

  provisioner "local-exec" {
    # here is your CLI command to create the ML
    command = ""
  }
}

虽然 Charles 提供了一些有效的解决方法,但我正在为 terraform-provider-azurerm 创建那些与 ML 相关的资源。请查看此 PR:https://github.com/terraform-providers/terraform-provider-azurerm/pull/5696

一旦此 PR 获得批准、合并和发布,您将能够使用 Terraform 在本地创建 ML 工作区。 其他ml相关资源也在计划中。

与此同时,Microsoft 在 Azure Provider 中为 ML Workspace 添加了 Terraform 资源。这应该会使任何自定义脚本过时。

https://www.terraform.io/docs/providers/azurerm/r/machine_learning_workspace.html

resource "azurerm_machine_learning_workspace" "example" {
  name                    = "example-workspace"
  location                = azurerm_resource_group.example.location
  resource_group_name     = azurerm_resource_group.example.name
  application_insights_id = azurerm_application_insights.example.id
  key_vault_id            = azurerm_key_vault.example.id
  storage_account_id      = azurerm_storage_account.example.id

  identity {
    type = "SystemAssigned"
  }
}