如何使用 Terraform 连接到 Azure?

如何使用 Terraform 连接到 Azure?

已从 Azure 门户检索多个值并将其复制到以下文件,例如 A、B、C 和 D:

主文件

provider "azurerm" {
  subscription_id = "A"
  client_id       = "B"
  client_secret   = "C"
  tenant_id       = "D"
}

运行terraform apply,结果为:

Error refreshing state: 1 error(s) occurred:

* Credentials for acessing the Azure Resource Manager API are likely to be 
incorrect, or the service principal does not have permission to use the Azure
Service Management API.

尝试解决问题

虽然Windows Azure Management API被选中并随后Access Azure Service Management as organization users (preview)被添加,但再次运行后问题仍然存在terraform apply

第二次尝试

下列的步骤本教程的结果是,在经典门户而不是新门户中创建虚拟网络。

Apublish_settings 文件已下载并用于以下配置片段:

provider "azure" {
  publish_settings = "${file("file.publishsettings")}"
}

resource "azure_virtual_network" "default" {
  name = "vNet01"
  address_space = ["10.0.0.1/24"]
  location = "North Europe"
  subnet {
  name = "Subnet1"
  address_prefix = "10.0.0.1/25"
 }
}

相关内容