包含自定义数据的 Azure VM 启动后,您可以在 VM 实例中找到/tmp/hello.txt文件。 总结 以上是如何使用 Terraform 将自定义数据传递给 Azure VM 的方法。使用 cloud-init 传递自定义数据的好处是可以使用众多内置模块来完成一些常见的配置,例如安装包、运行脚本和编写文件。我们也可以在azurerm_linux_virtual_machine...
Azure CLI az vm list\--resource-group$resource_group_name\--query"[].{\"VM Name\":name}"-otable 清理资源 不再需要通过 Terraform 创建的资源时,请执行以下步骤: 运行terraform plan并指定destroy标志。 控制台复制 terraform plan -destroy -out main.destroy.tfplan ...
“Azure 上的 Terraform”文档:https://docs.microsoft.com/zh-cn/azure/developer/terraform/ 使用Terraform 在 Azure 中创建带有基础结构的 Linux VM:https://docs.microsoft.com/zh-cn/azure/developer/terraform/create-linux-virtual-machine-with-infrastructure#complete-terraform-script Install Azure CLI on Win...
default = "rg" } variable "username" { type = string description = "The username for the local account that will be created on the new VM." default = "azureadmin" } 创建名为 outputs.tf 的文件并插入下列代码: Terraform 复制 output "resource_group_name" { value = azurerm_resource_gr...
The required AzureBastion subnet /27 is already in vnet.tf. Images The management VM examples use modules. You don't have to use these and can use native resources or your own modules. This example repo is not prescriptive. The current VM modules use custom images. If you wish to create...
准备创建VM的Terraform模板 准备Terraform模板,参考Azure的官方文档:使用 Terraform 在 Azure 中创建带有基础结构的 Linux VM。可以一步一步的编写模板,也可全部COPY至本地,并命名为:terraform_azure.tf(名字可以随便改动,文件后缀名tf不可变)。 View Code
{var.vm_name}-ipConfig" subnet_id = "${azurerm_subnet.subnet1.id}" private_ip_address_allocation = "dynamic" public_ip_address_id = "${azurerm_public_ip.vm_public_ip.id}" } tags { environment = "${var.environment_tag}" } } resource "azurerm_virtual_machine" "virtual_machine" ...
"name": "mail@example.com", "type": "user" } } 如果有多个订阅,需要设置当前账户使用的订阅。 az account set --subscription 00000000-0000-0000-0000-000000000000 代码 脚本已经提交在 GitHub 上,可以访问https://github.com/addozhang/terraform-azure-sample获取。
之前写过一篇使用 Terraform 部署 Proxmox 虚拟机,那是一台 Core i7-8700 + 64G 的 Homelab 上搭建的虚拟机环境,这也是我一直以来的实验环境。直至去年加入微软 MVP 拿到了 Azure 的 credit,在需要资源较多或者拉取镜像频繁的情况下我也会选择使用 Azure 的虚拟机,尤其是最近经常在多集群的环境做测试。
通过azure-cli创建虚拟机 安装azure-cli 我的电脑是MacOS,安装如下: $ brew update-reset $ brew install azure-cli $ which az /usr/local/bin/az $ az version { "azure-cli": "2.44.1", "azure-cli-core": "2.44.1", "azure-cli-telemetry": "1.0.8", ...