gpt4 book ai didi

azure terraform 将 azure 文件共享附加到 Windows 计算机

转载 作者:行者123 更新时间:2023-12-03 04:13:55 25 4
gpt4 key购买 nike


问题陈述
我正在创建 Windows 操作系统的 Azure VM 集群。到目前为止,我可以创建 Azure 文件共享。和 azure 的Windows集群。我想将创建的文件共享附加到集群中的每个虚拟机。无法找到如何在 Windows VM 上添加相同内容的引用。

此代码

resource "azurerm_storage_account" "main" {
name = "stor${var.environment}${var.cost_centre}${var.project}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
account_tier = "${var.storage_account_tier}"
account_replication_type = "${var.storage_replication_type}"
}


resource "azurerm_storage_share" "main" {
name = "storageshare${var.environment}${var.cost_centre}${var.project}"

resource_group_name = "${azurerm_resource_group.main.name}"
storage_account_name = "${azurerm_storage_account.main.name}"

quota = "${var.storage_share_quota}"
}

resource "azurerm_virtual_machine" "vm" {
name = "vm-${var.location_id}-${var.environment}-${var.cost_centre}-${var.project}-${var.seq_id}-${count.index}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
availability_set_id = "${azurerm_availability_set.main.id}"
vm_size = "${var.vm_size}"
network_interface_ids = ["${element(azurerm_network_interface.main.*.id, count.index)}"]
count = "${var.vm_count}"

storage_image_reference {
publisher = "${var.image_publisher}"
offer = "${var.image_offer}"
sku = "${var.image_sku}"
version = "${var.image_version}"
}

storage_os_disk {
name = "osdisk${count.index}"
create_option = "FromImage"
}

os_profile {
computer_name = "${var.vm_name}-${count.index}"
admin_username = "${var.admin_username}"
admin_password = "${var.admin_password}"
}

os_profile_windows_config {}

depends_on = ["azurerm_network_interface.main"]

}

最佳答案

Azure 不提供类似的功能,因此您无法在本地执行此操作,您需要创建一个脚本并在虚拟机上运行该脚本,使用脚本扩展\dsc 扩展,或者如果 terraform 支持该功能 - 使用 terraform。

https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux

关于azure terraform 将 azure 文件共享附加到 Windows 计算机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54817779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com